Submission #1019517

#TimeUsernameProblemLanguageResultExecution timeMemory
1019517LeaRouseComparing Plants (IOI20_plants)C++14
0 / 100
1 ms440 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 10; int n,p[MAX],k,ord[MAX]; set<int> s; void init(int k, std::vector<int> r) { n = r.size(); k = k; for(int i = 0; i < n; i++){ if(r[i] == 0) s.insert(i); p[i] = r[i]; } int c = n; while(!s.size()){ int maxi = -1,ant = -1, pri = -1; for(int x:s){ if(ant== -1) pri = x,ant = x; else{ if(x-ant>=k){ maxi = x; break; } ant = x; } } if(maxi == -1) maxi = pri; for(int i = maxi-k+1; i < maxi; i++){ int ind = i?i>=0:i+n; p[ind]--; if(p[ind] == 0) s.insert(ind); } ord[maxi] = c--; s.erase(maxi); } } int compare_plants(int x, int y) { return ord[x] > ord[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...