#include "plants.h"
#include <queue>
#include <cassert>
#define pb push_back
using namespace std;
vector<int> h;
void init(int k, vector<int> r) {
int n = r.size();
int x = n;
h.resize(n);
for (int i = 0; i < n; ++i) {
r.pb(r[i]);
}
for (int i = 0; i < n; ++i) {
queue<int> q;
for (int j = 0; j < n; ++j) {
if (!q.empty() && j - q.front() > k - 1) q.pop();
if (r[j] == 0) q.push(r[j]);
}
int cur = 0;
for (int j = n; j < 2*n; ++j) {
if (!q.empty() && j - q.front() > k - 1) q.pop();
if (r[j] == 0 && q.empty()){
cur = j;
break;
}
if (r[j] == 0) q.push(r[j]);
}
assert(cur >= n);
h[cur%n] = x--;
for (int j = cur; j > cur - k ; --j) {
r[j]--;
if (j >= n) r[j-n]--;
else r[j+n]--;
}
}
}
int compare_plants(int x, int y) {
if (h[x] > h[y]) return 1;
else return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
276 KB |
Output is correct |
4 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
272 KB |
Output is correct |
3 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
276 KB |
Output is correct |
4 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |