3665

1 /*
2 模拟,读懂题
3 */
4 // include file
5 #include <cstdio>
6 #include <cstdlib>
7 #include <cstring>
8 #include <cmath>
9 #include <cctype>
10 #include <ctime>
11
12 #include <iostream>
13 #include <sstream>
14 #include <fstream>
15 #include <iomanip>
16 #include <bitset>
17 #include <strstream>
18
19 #include <algorithm>
20 #include <string>
21 #include <vector>
22 #include <queue>
23 #include <set>
24 #include <list>
25 #include <functional>
26
27 using namespace std;
28
29 // typedef
30 typedef long long LL;
31 typedef unsigned long long ULL;
32
33 //
34 #define read freopen("in.txt","r",stdin)
35 #define write freopen("out.txt","w",stdout)
36 #define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
37 #define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
38
39 #define FF(i,a) for(int i=0;i<(a);i+++)
40 #define FFD(i,a) for(int i=(a)-1;i>=0;i--)
41 #define Z(a) (a<<1)
42 #define Y(a) (a>>1)
43
44 const double eps = 1e-11;
45 const double Pi = acos(-1.0);
46
47 template<class T> inline T sqr(T a){return a*a;}
48 template<class T> inline T TMAX(T x,T y)
49 {
50 if(x>y) return x;
51 return y;
52 }
53 template<class T> inline T TMIN(T x,T y)
54 {
55 if(x<y) return x;
56 return y;
57 }
58 template<class T> inline void SWAP(T &x,T &y)
59 {
60 T t = x;
61 x = y;
62 y = t;
63 }
64 template<class T> inline T MMAX(T x,T y,T z)
65 {
66 return TMAX(TMAX(x,y),z);
67 }
68
69
70 // code begin
71 int N,T;
72 /*
73 struct node
74 {
75 int number;
76 int rate;
77
78 friend bool operator<(node a,node b)
79 {
80 if( a.rate==b.rate )
81 {
82 return a.number>b.number;
83 }
84 return a.rate<b.rate;
85 }
86 };
87
88 struct node2
89 {
90 int number;
91 int rate;
92 friend bool operator<(node2 a,node2 b)
93 {
94 return a.number<b.number;
95 }
96 };
97
98 node A[1100];
99 node2 B[1100];
100
101 int main()
102 {
103 read;
104 write;
105 while(scanf("%d %d",&N,&T)!=-1)
106 {
107 FORi(0,N,1)
108 {
109 scanf("%d",&A[i].rate);
110 A[i].number = i+1;
111 }
112
113 make_heap(A,A+N);
114
115 FORi(0,T,1)
116 {
117 printf("%d\n",A[0].number);
118 int t = A[0].rate;
119 A[0].rate = 0;
120 if(t%(N-1)==0)
121 {
122 FORj(1,N,1)
123 {
124 A[j].rate += t/(N-1);
125 }
126 }
127 else
128 {
129 int tt = t%(N-1);
130
131 FORj(1,N,1)
132 {
133 A[j].rate += t/(N-1);
134 }
135
136 FORj(0,N,1){
137 B[j].number = A[j].number;
138 B[j].rate = A[j].rate;
139 }
140 sort(B,B+N);
141
142 FORj(1,N+1,1)
143 {
144 if(j==A[0].number) continue;
145 B[j-1].rate++;
146 tt--;
147 if(tt==0) break;
148 }
149
150 FORj(0,N,1)
151 {
152 A[j].number = B[j].number;
153 A[j].rate = B[j].rate;
154 }
155 }
156 make_heap(A,A+N);
157 }
158 }
159 return 0;
160 }
161
162 */
163 int R[1100];
164 int main()
165 {
166 read;
167 write;
168 while(scanf("%d %d",&N,&T)!=-1)
169 {
170 FORi(1,N+1,1)
171 {
172 scanf("%d",&R[i]);
173 }
174 FORi(0,T,1)
175 {
176 int maxdz;
177 int maxr = 0;
178 FORj(1,N+1,1)
179 {
180 if(R[j]>maxr)
181 {
182 maxr = R[j];
183 maxdz = j;
184 }
185 }
186
187 printf("%d\n",maxdz);
188 int zc = maxr/(N-1);
189 int ys = maxr%(N-1);
190 FORj(1,N+1,1)
191 {
192 R[j]+=zc;
193 }
194
195 FORj(1,ys+1,1)
196 {
197 R[j]++;
198 if(j==maxdz) ys++;
199 }
200
201 R[maxdz]=0;
202 }
203 }
204 return 0;
205 }
posted @ 2011-03-02 00:45  AC2012  阅读(512)  评论(0)    收藏  举报