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;
vector<int> h; // recovered
void init(int k, vector<int> r) {
int n = r.size();
h.resize(n, 0);
for (int it = 0; it < n; it++) {
int m1 = -1;
int m2 = -1;
for (int i = 0; i < n; i++) {
if (r[i] == 0) {
if (m1 == -1)
m1 = i;
else
m2 = i;
}
}
if (m2 != -1 && m2 - m1 >= k)
m1 = m2;
h[m1] = n - it;
for (int i = 1; i < k; i++) {
r[(m1 + n - i) % n]--;
}
}
}
int compare_plants(int x, int y) { return h[x] > h[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... |