제출 #560604

#제출 시각아이디문제언어결과실행 시간메모리
560604Ooops_sorryThe short shank; Redemption (BOI21_prison)C++14
35 / 100
2097 ms68504 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ld long double #define ll long long mt19937 rnd(51); const int N = 2e6 + 10; vector<int> g[N], used(N), mas; int dfs(int v) { used[v] = 1; if (g[v].size() == 0) { return 1; } vector<int> arr; for (auto to : g[v]) { arr.pb(dfs(to)); } sort(arr.rbegin(), arr.rend()); for (int j = 1; j < arr.size(); j++) mas.pb(arr[j]); return arr[0] + 1; } signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LCOAL ios_base::sync_with_stdio(0); cin.tie(0); int n, d, T, ans = 0; cin >> n >> d >> T; vector<int> t(n), go(n, -1); for (int i = 0; i < n; i++) { cin >> t[i]; } for (int i = 0; i < n; i++) { if (t[i] > T) { for (int j = i - 1; j >= 0; j--) { if (t[j] + (i - j) <= T) { go[i] = j; ans++; break; } } } else { ans++; } } deque<pair<int,int>> q; for (int i = n - 1; i >= 0; i--) { while (q.size() > 0 && q.back().first > i) { q.pop_back(); } if (go[i] != -1) { if (q.size() > 0) { g[q.back().second].pb(i); } q.pb({go[i], i}); } } for (int i = n - 1; i >= 0; i--) { if (!used[i]) { int val = dfs(i); mas.pb(val); } } sort(mas.rbegin(), mas.rend()); for (int i = 0; i < min((int)mas.size(), d); i++) { ans -= mas[i]; } cout << ans << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'int dfs(int)':
prison.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int j = 1; j < arr.size(); j++) mas.pb(arr[j]);
      |                     ~~^~~~~~~~~~~~
#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...