제출 #400006

#제출 시각아이디문제언어결과실행 시간메모리
400006Osama_AlkhodairyThe short shank; Redemption (BOI21_prison)C++17
0 / 100
83 ms7240 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long int n, d, t; vector <int> a; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> d >> t; a.resize(n); for(auto &i : a) cin >> i; vector <int> g(n); for(int i = n - 2 ; i >= 0 ; i--){ if(a[i + 1] <= t) g[i] = 0; else g[i] = g[i + 1] + 1; } vector <int> all; for(int i = 0 ; i + 1 < n ; i++){ if(a[i] <= t && a[i + 1] <= t){ a[i + 1] = min(a[i + 1], a[i] + 1); } } for(int i = 0 ; i + 1 < n ; i++){ if(a[i] <= t && a[i + 1] > t){ all.push_back(min(g[i], t - a[i])); } } sort(all.begin(), all.end()); int ans = 0; for(int i = 0 ; i < n ; i++){ ans += a[i] <= t; } while(all.size() && d > 0){ all.pop_back(); d--; } for(auto &i : all) ans += i; cout << ans << "\n"; }
#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...