#include "plants.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
const int N = 200100;
const int oo = 2e9;
vector<int> vc;
int per[N];
void init(int k, vector<int> r) {
int n = sz(r);
// assert(2 * k > n);
for (int it = n - 1; it >= 0; it--){
vc.clear();
for (int i = 0; i < n; i++)
if (r[i] == 0)
vc.PB(i);
int cand = -1;
for (int it = 0; it < sz(vc); it++){
int cur = vc[it];
int pre = vc[(it + sz(vc) - 1) % sz(vc)];
if (pre < cur){
if (cur - pre + n < k){
cand = cur;
break;
}
} else {
if (cur - pre < k){
cand = cur;
break;
}
}
}
per[cand] = it;
r[cand] = oo;
for (int i = 1, loc = cand; i < k; i++){
loc = (loc + n - 1) % n;
r[loc]--;
}
}
return;
}
int compare_plants(int x, int y) {
return (per[x] > per[y] ? 1 : -1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Runtime error |
3 ms |
672 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Runtime error |
3 ms |
616 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |