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;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 3e5 + 5;
ll a[NN], n;
void init(int k, std::vector<int> r) {
	n = r.size();
	for(ll i = 0; i < n; i++)
	{
		ll idx = 0;
		vector<ll> tmp;
		for(ll j = 0; j < n; j++)
			if(r[j] == 0)
				tmp.pb(j);
		if(tmp.size() == 1)
			idx = tmp[0];
		else
		if(tmp[0] + k > tmp[1])
			idx = tmp[0];
		else
			idx = tmp[1];
		a[idx] = n - i; 
		r[idx] = 1e9;
		for(ll j = idx - 1; j > (idx - k); j--)
			r[(j + n) % n]--;
		// cout << idx << " " << a[idx] << "\n"; 
	}
	return;
}
int compare_plants(int x, int y) {
	return (a[x] > a[y]);
}
| # | 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... |