Submission #1083676

#TimeUsernameProblemLanguageResultExecution timeMemory
1083676fv3Comparing Plants (IOI20_plants)C++17
14 / 100
4030 ms9552 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; int K, N; vector<int> R; bool check(int s) { int cnt = 0; for (int i = s - 1; i >= 0 && cnt < K - 1; i--, cnt++) if (!R[i]) return false; for (int i = N - 1; cnt < K - 1; i--, cnt++) if (!R[i]) return false; cnt = 0; for (int i = s - 1; i >= 0 && cnt < K - 1; i--, cnt++) R[i]--; for (int i = N - 1; cnt < K - 1; i--, cnt++) R[i]--; return true; } vector<int> H; void init(int k, vector<int> r) { R = r; K = k; N = (int)r.size(); // Find ordering in O(N²) H = vector<int>(N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (R[j]) continue; if (check(j)) { H[j] = N - i; R[j] = INF; break; } } } } int compare_plants(int x, int y) { if (H[x] > H[y]) return 1; return -1; } #ifdef TEST #include "grader.cpp" #endif
#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...