#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]) {
if(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];
}
}
}
int compare_plants(int x, int y) {
if(val[x]>val[y]) return 1;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |