제출 #1222213

#제출 시각아이디문제언어결과실행 시간메모리
1222213kargneq식물 비교 (IOI20_plants)C++20
14 / 100
4094 ms6472 KiB
#include <bits/stdc++.h> #include <vector> using namespace std; vector<int> r, height; int n, k; void init(int kk, vector<int> rr) { r = rr; n = r.size(); k = kk; height.assign(n, 0); vector<int> rr_copy = r; vector<bool> used(n, false); for (int h = n; h >= 1; --h) { int idx = -1; for (int i = 0; i < n; ++i) { if (used[i]) continue; if (rr_copy[i] == 0) { bool ok = true; for (int j = 1; j < k; ++j) { int prev = (i - j + n) % n; if (!used[prev] && rr_copy[prev] == 0) { ok = false; break; } } if (ok) { idx = i; break; } } } height[idx] = h; used[idx] = true; for (int j = 0; j < k; ++j) { int prev = (idx - j + n) % n; if (!used[prev]) rr_copy[prev]--; } } } int compare_plants(int x, int y) { if (height[x] > height[y]) return 1; if (height[x] < height[y]) return -1; return 0; }
#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...