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;
int n, pos[100100],CA;
vector<int> R;
set<int> CD;
void init(int k, std::vector<int> r) {
R=r;
n=r.size();
for(int i=0;i<n;i++)
if(!r[i])
CD.insert(i);
while(CD.size()){
int bst=*CD.begin(),gp=*CD.begin()+n-*--CD.end();
auto it=++CD.begin();
while(it!=CD.end()){
int G=*it-*prev(it);
if(G>gp)
gp=G,bst=*it;
it++;
}
pos[bst]=++CA;
CD.erase(bst);
for(int i=1;i<k;i++){
int c=(bst+n-i)%n;
if(!--R[c])
CD.insert(c);
}
}
}
int compare_plants(int x, int y) {
return pos[x]<pos[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... |