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;
#define vi vector<int>
vi ranking;
void init(int k, std::vector<int> r) {
k--;
int n = r.size();
ranking.resize(n);
for(int i = 0; i<n; i++) {
int window = 0;
for(int l = 0;l<k; l++){
window+=(r[l]==0);
}
int j;
for(j = k; j<n+k; j++){
int pos = j%n;
if(r[pos]==0&&window==0) goto found;
window-=r[j-k]==0;
window+=(r[pos]==0);
}
found:
for(int l = 1; l<=k; l++){if(r[(j-l+n)%n]>0) r[(j-l+n)%n]--;}
r[j%n]=INT_MIN;
ranking[j%n] = i;
}
}
int compare_plants(int x, int y) {
if(ranking[x]<ranking[y]) return 1;
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... |