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 <iostream>
#include <algorithm>
using namespace std;
#define len(a) ((int)(a).size())
vector<int> v, m, c;
int compare_plants(int x, int y) {
if(v[x] > v[y]) return 1;
return -1;
}
void init(int k, vector<int> r) {
v.resize(len(r));
m.resize(len(r));
c.resize(len(r));
int x = len(r);
while(x--){
// cout << x << " ";
for(int i = 0; i < len(r); i++){
m[i] = 1000000009; c[i] = 0;
for(int j = i + 1; j < i + k; j++){
if(r[j % len(r)] == -1) c[i]++;
}
for(int j = i + len(r) - 1; j >= i + len(r) - k; j--){
if(r[j % len(r)] != -1) m[i] = min(m[i], r[j % len(r)]);
}
}
int mn = 1000000009;
for(int i = 0; i < len(r); i++){
if(r[i] != -1) mn = min(mn, r[i] - c[i]);
}
// cout << mn << " ";
for(int i = 0; i < len(r); i++){
if(r[i] - c[i] == mn && m[i] > mn){
// cout << i << " " << m[i] << endl;
v[i] = x;
r[i] = -1;
break;
}
}
}
// for(int i = 0; i < len(r); i++){
// cout << v[i] << " ";
// }
// cout << endl;
}
# | 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... |