제출 #639715

#제출 시각아이디문제언어결과실행 시간메모리
639715tabr휴가 (IOI14_holiday)C++17
0 / 100
5054 ms4144 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif long long findMaxAttraction(int n, int s, int d, int a[]) { long long res = (long long) -9e18; for (int dir = 0; dir < 2; dir++) { priority_queue<long long, vector<long long>, greater<long long>> pq; long long sum = 0; for (int i = s; i < n; i++) { pq.emplace(a[i]); sum += a[i]; while (!pq.empty() && (int) pq.size() + i > d) { sum -= pq.top(); pq.pop(); } res = max(res, sum); auto pq2 = pq; auto sum2 = sum; for (int j = s - 1; j >= 0; j--) { pq.emplace(a[j]); sum += a[j]; while (!pq.empty() && (int) pq.size() + i + (s - j) * 2 > d) { sum -= pq.top(); pq.pop(); } res = max(res, sum); } swap(pq, pq2); swap(sum, sum2); } reverse(a, a + n); s = n - 1 - s; } return res; } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; } #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...