제출 #614968

#제출 시각아이디문제언어결과실행 시간메모리
614968cheissmart휴가 (IOI14_holiday)C++14
24 / 100
5041 ms2196 KiB
#include"holiday.h" #include <bits/stdc++.h> #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7; ll go(int n, int s, int d, int a[]) { priority_queue<int, vi, greater<int>> pq; ll ans = 0, sum = 0; int cost = 0; for(int i = s; i < n; i++) { pq.push(a[i]); sum += a[i]; while(SZ(pq) + cost > d) { if(pq.empty()) return ans; sum -= pq.top(); pq.pop(); } ans = max(ans, sum); cost++; } return ans; } ll solve(int n, int s, int d, int a[]) { ll ans = 0; for(int i = s; i >= 0 && d; i--, d--) { ans = max(ans, go(n, i, d, a)); } return ans; } ll findMaxAttraction(int n, int s, int d, int a[]) { ll ans = solve(n, s, d, a); reverse(a, a + n); s = n - s - 1; ans = max(ans, solve(n, s, d, a)); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...