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;
using ll = long long;
int n;
int ord[5050];
void init(int k, vector<int> r) {
n = r.size();
memset(ord, -1, sizeof ord);
for (int i = 0;i < n;i++) {
vector<int> v;
for (int j = 0;j < n;j++) {
if (ord[j] == -1 && r[j] == 0) {
v.push_back(j);
}
}
int idx = 0;
for (int j = 0;j < (int)v.size();j++) {
if ((v[j] - v[(j + n - 1) % n] + n) % n >= k) idx = v[j];
}
ord[idx] = i;
for (int j = 1;j < k;j++) {
r[(idx - j + n) % n]--;
}
}
}
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... |