1 #include<stdio.h>
2 #include<string.h>
3 #include <math.h>
4 #define MAXSIZE 502
5 struct node {
6 int num;//对应数字
7 int big;//原序列中比该数字大的数字的数目
8 };
9 node num[MAXSIZE];
10 int t;//数组长度
11 inline void scan(int &x){
12 char ch;
13 while(ch=getchar(),ch<'0'||ch>'9');x=ch-'0';
14 while(ch=getchar(),ch>='0'&&ch<='9')x=10*x+ch-'0';
15 }
16 void MergeSort(int low,int len,int high){
17 int border=low+len;
18 while (low<border){
19 int i,pos=low;
20 node temp;
21 if(num[pos].big>0){
22 for(i=border;i<=high&&num[pos].big>0;i++){
23 if(num[pos].num<num[i].num){
24 temp=num[pos];
25 num[pos]=num[i];
26 num[i]=temp;
27 pos=i;
28 num[pos].big--;
29 }
30 }
31 }
32 low++;
33 }
34 }
35 void Merge(int low,int high){
36 if(low<high){
37 int mid=(int)ceil((low+high+1)/2.0);
38 Merge(low,mid-1);
39 Merge(mid,high);
40 MergeSort(low,(int)ceil((high-low+1)/2.0),high);
41 }
42 }
43
44 int main(){
45 #ifndef ONLINE_JUDGE
46 freopen("in.txt","r",stdin);
47 #endif
48 while (true){
49 scan(t);
50 if (t==0)
51 break;
52 int i;
53 for(i=0;i<t;i++){
54 scan(num[i].big);
55 num[i].num=i+1;
56 }
57 Merge(0,t-1);
58 printf("%d",num[0].num);
59 for(i=1;i<t;i++)
60 printf(",%d",num[i].num);
61 printf("\n");
62 }
63 return 0;
64 }
65
posted on 2012-05-17 08:30
Leo.W 阅读(157)
评论(0) 编辑 收藏 引用