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 <bits/stdc++.h>
#include "plants.h"
using namespace std;
typedef long long ll;
ll n1;
ll val;
vector<ll> a1;
void init(int k, vector<int> r) {
n1 = r.size();
val = n1;
a1 = vector<ll>(n1);
while (val > 0) {
ll id = 0;
for (int i = n1-1; i >= 0; i--) {
if (r[i] == 0) {
id = i;
break;
}
}
ll finId = id;
for (int i = 1; i < k && id > 0; i++) {
id--;
if (r[id] == 0) {
i = 1;
finId = id;
}
}
a1[finId] = val--;
for (int i = 1; i < k; i++) {
ll tId = (finId - i + n1) % n1;
r[tId]--;
}
a1[finId] = 1ll << 62ll;
}
}
int compare_plants(int x, int y) {
return a1[x] > a1[y] ? 1 : -1;
}
#ifdef TEST
#include "grader.cpp"
#endif
# | 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... |