This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// subtask 2*k > n, n <= 5000
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 2e5+10;
int ordem[maxn];
void init(int k, std::vector<int> r) {
int n = (int)(r.size());
for(int i = 0; i < n; i++) {
int mx = 0;
for(int j = 1; j < n; j++)
if(r[j] < mx || (r[j] == mx && (mx - j + n) < k))
mx = j;
ordem[mx] = i;
r[mx] = 0x3f3f3f3f;
for(int j = 0; j < k; j++)
--r[(mx - j + n) % n];
}
}
int compare_plants(int x, int y) {
return ordem[x] < ordem[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... |