#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
const int maxn = 2e5 + 5;
const int INF = 1e9;
#include "plants.h"
int rk[maxn];
int n, k;
vector<int> r;
void init(int _k, std::vector<int> _r) {
r = _r, k = _k;
n = r.size();
for(auto x : _r) r.pb(x);
auto del = [&](int x) -> void {
for(int i = max(0, x - k + 1); i < x; i++) r[i] --;
x += n;
for(int i = x - k + 1; i < x; i++) r[i] --;
};
for(int rd = 0; rd < n; rd++){
int csc = 0;
for(int i = 0; i < 2 * n; i++){
if(r[i] == 0){
if(csc >= n - k){
del(i % n);
rk[i % n] = rd;
r[i] = r[(i + n) % (2 * n)] = INF;
break;
}
csc = 0;
}
else csc++;
}
}
return;
}
int compare_plants(int x, int y) {\
return rk[x] < rk[y] ? 1 : -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
66 ms |
5052 KB |
Output is correct |
8 |
Correct |
1 ms |
540 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
69 ms |
5212 KB |
Output is correct |
11 |
Correct |
64 ms |
4948 KB |
Output is correct |
12 |
Correct |
64 ms |
5240 KB |
Output is correct |
13 |
Correct |
64 ms |
5052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
66 ms |
5052 KB |
Output is correct |
8 |
Correct |
1 ms |
540 KB |
Output is correct |
9 |
Correct |
3 ms |
348 KB |
Output is correct |
10 |
Correct |
69 ms |
5212 KB |
Output is correct |
11 |
Correct |
64 ms |
4948 KB |
Output is correct |
12 |
Correct |
64 ms |
5240 KB |
Output is correct |
13 |
Correct |
64 ms |
5052 KB |
Output is correct |
14 |
Correct |
450 ms |
5944 KB |
Output is correct |
15 |
Execution timed out |
4048 ms |
10412 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
452 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |