#include "plants.h"
#include "bits/stdc++.h"
using namespace std;
const int inf = 1e9;
vector<int> a;
int n;
void init(int k, vector<int> r) {
n = r.size();
a.resize(n);
for(int j=n;j>0;j--){
//~ for(int i=0;i<n;i++) cout<<r[i]<<" ";
//~ cout<<"\n";
int cnt = 0;
for(int i=0;i<k - 1;i++) cnt += (r[i] == 0);
int p = -1;
for(int i=k - 1;;){
if(!cnt && r[i] == 0){
p = i;
break;
}
cnt -= (r[(i + n - k + 1) % n] == 0);
cnt += (r[i] == 0);
i = (i + 1) % n;
if(i == k - 1) break;
}
//~ assert(~p);
assert(a[p] == 0);
//~ cout<<i<<endl;
r[p] = inf;
a[p] = j;
for(int i=0;i<n;i++){
if((i <= p && p < i + k) || (i <= p + n && p + n < i + k)){
r[i]--;
}
}
}
//~ for(int i=0;i<n;i++) cout<<a[i]<<" ";
//~ cout<<"\n";
return;
}
int compare_plants(int x, int y) {
if(a[x] > a[y]) return 1;
if(a[x] < a[y]) return -1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
7 ms |
308 KB |
Output is correct |
7 |
Correct |
175 ms |
5036 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
172 ms |
5068 KB |
Output is correct |
11 |
Correct |
168 ms |
4976 KB |
Output is correct |
12 |
Correct |
171 ms |
5224 KB |
Output is correct |
13 |
Correct |
171 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
7 ms |
308 KB |
Output is correct |
7 |
Correct |
175 ms |
5036 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
312 KB |
Output is correct |
10 |
Correct |
172 ms |
5068 KB |
Output is correct |
11 |
Correct |
168 ms |
4976 KB |
Output is correct |
12 |
Correct |
171 ms |
5224 KB |
Output is correct |
13 |
Correct |
171 ms |
5076 KB |
Output is correct |
14 |
Correct |
2172 ms |
5492 KB |
Output is correct |
15 |
Execution timed out |
4070 ms |
8660 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
59 ms |
4824 KB |
Output is correct |
4 |
Execution timed out |
4050 ms |
7904 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |