Submission #1019524

#TimeUsernameProblemLanguageResultExecution timeMemory
1019524LeaRouseComparing Plants (IOI20_plants)C++14
14 / 100
4067 ms11336 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>=0?i: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; } // 3 4 2 1 5 // k == 3 // 1 0 1 2 0 // 1 0 0 1 -1 // 0 -1 0 1 -1 // -1 -1 0 0 -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...