Submission #1081972

#TimeUsernameProblemLanguageResultExecution timeMemory
1081972woodComparing Plants (IOI20_plants)C++17
14 / 100
4099 ms8784 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> vi ranking; void init(int k, std::vector<int> r) { k--; int n = r.size(); ranking.resize(n); for(int i = 0; i<n; i++) { int window = 0; for(int l = 0;l<k; l++){ window+=(r[l]==0); } int j; for(j = k; j<n+k; j++){ int pos = j%n; if(r[pos]==0&&window==0) goto found; window-=r[j-k]==0; window+=(r[pos]==0); } found: for(int l = 1; l<=k; l++){if(r[(j-l+n)%n]>0) r[(j-l+n)%n]--;} r[j%n]=INT_MIN; ranking[j%n] = i; } } int compare_plants(int x, int y) { if(ranking[x]<ranking[y]) return 1; return -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...