Description [title]
There are n
Individual queues in front of a tap water connection, if each of the water receiving time T I , please find this programming n in a sequential individual queued, so that n
The average individual waiting time to a minimum.
[Enter]
A total of two rows, the first row n- (1 ≦ n- ≤1000)
; Second line respectively denote an individual to the second n individual contact of water per time T 1, T 2, ..., T n , between each of the data 1
Spaces.
[Output]
There are two lines, the first act of the queue sequence, i.e. 1
To n
One arrangement; average waiting time in the second embodiment are arranged such behavior (outputs the result to two decimal places).
[Sample input]
10 56 12 1 99 1000 234 33 55 99 812
[Sample Output]
3 2 7 8 1 4 9 6 10 5 291.90
// Created on 2020/2/11
/*#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <climits>*/
#include <bits/stdc++.h>
using namespace std;
//int i,j,k;
const int maxn=INT_MAX;
const int idata=1000+5;
int goal[idata],temp[idata];
int n,m;
bool flag;
long long sum,assume;
int main()
{
int i,j;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>goal[i];
temp[i]=i;
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(goal[i]>goal[j])
{
swap(goal[i],goal[j]);
swap(temp[i],temp[j]);
}
}
}
assume=goal[1];//注意:是等待时间
for(i=2;i<=n;i++)
{
sum+=assume;
assume+=goal[i];
}
for(i=1;i<=n;i++)
{
cout<<temp[i]<<" ";
}
cout<<endl;
printf("%.2lf\n",sum*1.0/n);
}