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;
const int MAX = 1e6 + 10;
int n,p[MAX],k,ord[MAX];
set<int> s;
void init(int k, std::vector<int> r) {
n = r.size();
k = k;
for(int i = 0; i < n; i++){
if(r[i] == 0) s.insert(i);
p[i] = r[i];
}
int c = n;
while(!s.size()){
int maxi = -1,ant = -1, pri = -1;
for(int x:s){
if(ant== -1) pri = x,ant = x;
else{
if(x-ant>=k){
maxi = x;
break;
}
ant = x;
}
}
if(maxi == -1) maxi = pri;
for(int i = maxi-k+1; i < maxi; i++){
int ind = i?i>=0:i+n;
p[ind]--;
if(p[ind] == 0) s.insert(ind);
}
ord[maxi] = c--;
s.erase(maxi);
}
}
int compare_plants(int x, int y) {
return ord[x] > ord[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... |