Submission #1043844

#TimeUsernameProblemLanguageResultExecution timeMemory
1043844aaaaaarrozComparing Plants (IOI20_plants)C++17
14 / 100
4046 ms13676 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; int n, pos[100100],CA; vector<int> R; set<int> CD; void init(int k, std::vector<int> r) { R=r; n=r.size(); for(int i=0;i<n;i++) if(!r[i]) CD.insert(i); while(CD.size()){ int bst=*CD.begin(),gp=*CD.begin()+n-*--CD.end(); auto it=++CD.begin(); while(it!=CD.end()){ int G=*it-*prev(it); if(G>gp) gp=G,bst=*it; it++; } pos[bst]=++CA; CD.erase(bst); for(int i=1;i<k;i++){ int c=(bst+n-i)%n; if(!--R[c]) CD.insert(c); } } } int compare_plants(int x, int y) { return pos[x]<pos[y]?1:-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...