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 "plants.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
vector<ll> r,rk;
ll n,k;
void init(int K, std::vector<int> R) {
n = R.size();
k = K;
r = R;
rk.resize(n,-1);
vector<ll> a = R;
for(ll t = 0;t<n;t++){
vector<ll> zs;
for(ll i = 0;i<n;i++) if(rk[i]==-1&&a[i]<=0) zs.push_back(i);
ll zz = zs[0];
if(zs.size()>1){
if ((zs[0]-zs[1]+n)%n<=k-1)zz = zs[1];
}
rk[zz] = t;
for(ll i = 1;i<k;i++) a[(zz-i+n)%n]--;
}
}
int compare_plants(int x, int y) {
cerr << rk.size() << " " << x << " " << y << endl;
if (rk[x]<rk[y]) return 1;
else return -1;
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... |