# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431112 | Pbezz | Comparing Plants (IOI20_plants) | C++14 | 1 ms | 332 KiB |
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;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
const ll INF = 1e9+7;
ll order[MAXN],n;
void init(int k, std::vector<int> r) {
ll l,i,cur,n=(ll)r.size();
for(l=n;l>=1;l--){//find current maximum
vector<ll>meh;//cout<<l<<"\n";
for(i=0;i<n;i++){//cout<<r[i]<<" ";
if(r[i]==0)meh.pb(i);
}
// if((int)meh.size()==0)break;
if((int)meh.size()==1){
cur=meh[0];
}else{
for(i=1;i<(ll)meh.size();i++){
if(meh[i]-meh[i-1]>k){
cur=meh[i]; break;
}
}
if(n-meh[meh.size()-1]+meh[0]>k)cur=meh[0];
}//cout<<"# ha "<<cur<<endl;
order[cur]=l;
r[cur]=-1;
for(i=0;i<k-1;i++){
cur--;
if(cur<0)cur=n-1;
r[cur]--;
}
//cout<<l<<" "<<2<<endl;
}
//for(ll i=0;i<n;i++)cout<<order[i]<<" k ";
//cout<<endl;
return;
}
int compare_plants(int x, int y) {
if(order[x]>order[y])return 1;
return -1;
return 0;
}
Compilation message (stderr)
# | 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... |