제출 #1015390

#제출 시각아이디문제언어결과실행 시간메모리
1015390parsadox2휴가 (IOI14_holiday)C++17
47 / 100
5048 ms5468 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if(d == 0) return 0; long long ans = attraction[start]; for(int l = 0 ; l <= start ; l++) { multiset <int> st; long long sum = 0; for(int i = l ; i <= start ; i++) { sum += attraction[i]; st.insert(attraction[i]); } int D = d - (start - l); int sz = st.size(); //cout << st.size() << " WTF " << D << endl; while(!st.empty() && sz > D) { sum -= *st.begin(); st.erase(st.begin()); sz = st.size(); } ans = max(ans , sum); //cout << l << " " << start << " : " << D << " " << sum << endl; for(int r = start + 1 ; r < n ; r++) { st.insert(attraction[r]); sum += attraction[r]; sz = st.size(); D = d - (r - l) - min(r - start , start - l); while(!st.empty() && sz > D) { sum -= *st.begin(); st.erase(st.begin()); sz = st.size(); } ans = max(ans , sum); //cout << l << " " << r<< " : " << D << " " << sum << endl; } } 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...