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 "grader.cpp"
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
using namespace std;
const int N=2e5+5;
int ans[N];
void init(int k, vector<int> r) {
int n=r.size();
for(int t=n-1;t>=0;t--){
vector<int> a;
for(int i=0;i<n;i++) if(r[i]==0) a.pb(i);
int v=0;
for(int i=0;i<(int)a.size();i++){
if(i==0){
if(a[i]-(a.back()-n)>=k){
v=a[i];
break;
}
}
else{
if(a[i]-a[i-1]>=k){
v=a[i];
break;
}
}
}
for(int i=v-k+1;i<=v;i++){
if(r[(i+n)%n]!=-1)
r[(i+n)%n]--;
}
r[v]=-1;
ans[v]=t;
}
}
int compare_plants(int x, int y) {
if(ans[x]>ans[y]) return 1;
else return -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... |