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) {
int n = r.size();
ranking.resize(n);
bool done[n]; memset(done,0,sizeof done);
for(int i = 0; i<n; i++){
int window = 0;
for(int j = 0; j<k; j++){
window+=r[j+1]==0;
r[j]--;
r[j] = max(r[j],0);
}
int j = 0;
if(!done[0]&&window==0) goto found;
for(j = 1;j<n; j++){
window+=r[(j+k-1)%n]==0;
window-=r[j-1]==0;
r[(j+k-1)%n]--;
r[(j+k-1)%n] = max(r[(j+k-1)%n],0);
r[j-1]++;
if(done[j]) continue;
if(window==0) goto found;
}
found:
done[j] = true;
ranking[j] = 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... |