#include "plants.h"
#include <bits/stdc++.h>
constexpr int N = 2E5;
int n;
int h[N];
void init(int k, std::vector<int> r) {
n = r.size();
auto dec = [&](int s, int e) {
while (s != e) {
r[s]--;
s = (s == n - 1 ? 0 : s + 1);
}
r[e]--;
};
for (int cur = n - 1; cur >= 0; cur--) {
for (int s = 0, e = k - 1, cnt = std::count(r.begin(), r.begin() + k, 0); s < n; s++, e = (e == n - 1 ? 0 : e + 1)) {
if (r[e] == 0 && cnt == 1) {
h[e] = cur;
dec(s, e);
break;
}
// std::cout << "rep";
cnt -= (r[s] == 0);
cnt += (r[(e + 1) % n] == 0);
}
}
return;
}
int compare_plants(int x, int y) {
if (h[x] > h[y]) {
return 1;
} else if (h[x] < h[y]) {
return -1;
} else {
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |