제출 #574359

#제출 시각아이디문제언어결과실행 시간메모리
574359MadokaMagicaFan휴가 (IOI14_holiday)C++14
23 / 100
17 ms2068 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define sz(v) ((int)v.size()) #define pb push_back #define pry cout << "YES\n" #define prn cout << "NO\n" #define endl '\n' #define fst first #define scn second ll findMaxAttraction(int n, int s, int d, int a[]) { assert(s==0); priority_queue<int, vector<int>, greater<int>> q; ll ans = 0; ll sum = 0; int cnt; for (int i = 0; i < n; ++i) { if (i + 1 > d) break; cnt = d-i-1; while (sz(q) > cnt) { sum -= q.top(); q.pop(); } ans = max(ans,sum+a[i]); q.push(a[i]); sum += a[i]; } return ans; } #ifdef ONPC void solve() { int n, s, d; cin >> n >> s >> d; int a[n]; for (int i = 0; i < n; ++i) cin >> a[i]; cout << findMaxAttraction(n,s,d,a) << endl; } int32_t main(int argc, char **argv) { if (argc >= 2) { freopen(argv[1], "r", stdin); } else ios_base::sync_with_stdio(0);cin.tie(0); int t = 1; /* cin >> t; */ while(t--) solve(); } #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...