Submission #1020519

#TimeUsernameProblemLanguageResultExecution timeMemory
1020519alex_2008Comparing Plants (IOI20_plants)C++14
14 / 100
4009 ms9552 KiB
#include "plants.h" #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <set> #include <map> typedef long long ll; using namespace std; const int N = 2e5 + 10; int r[N], perm[N]; int val[N]; int n, k; void init(int K, vector<int> R) { k = K; n = (int)R.size(); for (int i = 1; i <= n; i++) { r[i] = R[i - 1]; } for (int i = n; i >= 1; i--) { int last = -1; for (int j = 1; j <= n; j++) { if (r[j] != 0) continue; if (last == -1 || (last + (k - 1) < j)) last = j; } r[last] = -1; perm[last] = i; for (int l = max(1, (last - k + 1)); l < last; l++) { r[l]--; } if ((last - k + 1) < 1) { int mnac = (k - 1) - (last - 1); for (int l = n; l > n - mnac; l--) { r[l]--; } } } } int compare_plants(int x, int y) { x++; y++; if (perm[x] > perm[y]) return 1; return -1; } /* int main() { init(3, { 2, 1, 0, 2, 1 }); for (int i = 1; i <= 5; i++) { cout << perm[i] << " "; } } */
#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...