#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
using int64 = long long;
using ld = long double;
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
vector<int> h;
int n = -1;
void init(int k, vector<int> r) {
n = r.size();
r.insert(r.end(), r.begin(), r.end());
h.resize(n);
auto dec = [&](const int i) {
r[i]--;
(i >= n ? r[i - n] : r[i + n])--;
};
vector<bool> taken(2 * n);
for (int i = n, ht = n; ht > 0; i++) {
if (i == 2 * n) i = n;
if (taken[i] or r[i] != 0) continue;
bool good = true;
for (int j = i - k + 1; j < i; j++) {
good &= (r[j] != 0) or taken[j];
}
if (not good) continue;
for (int j = i - k + 1; j < i; j++) {
dec(j);
}
taken[i] = taken[i - n] = true;
h[i - n] = ht;
ht--;
}
}
int compare_plants(int x, int y) {
return (h[x] > h[y] ? 1 : -1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
150 ms |
5044 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
340 KB |
Output is correct |
10 |
Correct |
167 ms |
5096 KB |
Output is correct |
11 |
Correct |
91 ms |
5000 KB |
Output is correct |
12 |
Correct |
128 ms |
5208 KB |
Output is correct |
13 |
Correct |
170 ms |
5088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
6 ms |
340 KB |
Output is correct |
7 |
Correct |
150 ms |
5044 KB |
Output is correct |
8 |
Correct |
3 ms |
340 KB |
Output is correct |
9 |
Correct |
6 ms |
340 KB |
Output is correct |
10 |
Correct |
167 ms |
5096 KB |
Output is correct |
11 |
Correct |
91 ms |
5000 KB |
Output is correct |
12 |
Correct |
128 ms |
5208 KB |
Output is correct |
13 |
Correct |
170 ms |
5088 KB |
Output is correct |
14 |
Correct |
1534 ms |
5444 KB |
Output is correct |
15 |
Execution timed out |
4051 ms |
9552 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
47 ms |
4820 KB |
Output is correct |
4 |
Execution timed out |
4043 ms |
8668 KB |
Time limit exceeded |
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 |
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 |
276 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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |