This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | 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... |