#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
const int nax = 5002;
int val[nax], n, k;
bool done[nax];
bool cmp(int x, int y) {
if(x + k - 1 < n) {
return y > x && y <= x + k - 1;
} else {
if(y < x) return (x + k - 1) % n >= y;
else return y > x;
}
}
void init(int K, vector<int> r) {
k = K;
n = r.size();
for(int tg=1; tg<=n; ++tg) {
int mn = -1;
for(int i=0; i<n; ++i) if(!done[i] && r[i]==k-1) {
if(mn==-1) mn = i;
else if(!cmp(mn, i)) mn = i;
}
val[mn] = tg;
done[mn] = true;
for(int i=mn, cnt=0; cnt<k; ++cnt, i=(i-1+n)%n) {
++r[i];
}
}
// for(int i=0; i<n; ++i) {
// cerr<<val[i]<<' ';
// }
// cerr<<'\n';
}
int compare_plants(int x, int y) {
if(val[x]>val[y]) return 1;
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
160 ms |
4980 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
408 KB |
Output is correct |
10 |
Correct |
156 ms |
5100 KB |
Output is correct |
11 |
Correct |
109 ms |
4976 KB |
Output is correct |
12 |
Correct |
124 ms |
5096 KB |
Output is correct |
13 |
Correct |
182 ms |
4984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
160 ms |
4980 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
408 KB |
Output is correct |
10 |
Correct |
156 ms |
5100 KB |
Output is correct |
11 |
Correct |
109 ms |
4976 KB |
Output is correct |
12 |
Correct |
124 ms |
5096 KB |
Output is correct |
13 |
Correct |
182 ms |
4984 KB |
Output is correct |
14 |
Runtime error |
33 ms |
7700 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
35 ms |
6996 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |