제출 #1056564

#제출 시각아이디문제언어결과실행 시간메모리
1056564aymanrs휴가 (IOI14_holiday)C++17
0 / 100
5087 ms9808 KiB
#include"holiday.h" #include <set> using namespace std; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if(!d) return 0; int et = 4*n+10; long long le[et], l[et]; l[0]=le[0]=0;l[1]=le[1]=attraction[start]; fill(l+2, l+et, -1); fill(le+2, le+et, -1); multiset<int> s; s.insert(attraction[start]); for(int i = start+1;i < n;i++){ int e = 1; long long t = 0; s.insert(attraction[i]); for(auto it = s.rbegin();it != s.rend();it++,e++){ t += *it; l[e+i-start] = max(l[e+i-start], t); le[e+2*(i-start)] = max(l[e+2*(i-start)], t); } } long long ans = l[d]; s.clear(); for(int i = start-1;i >= 0;i--){ s.insert(attraction[i]); int e = 1;long long t = 0; for(auto it = s.rbegin();it != s.rend();it++,e++){ t += *it; if(e+2*(start-i) <= d) ans = max(ans, t+l[d-(e+2*(start-i))]); if(e+start-i <= d) ans = max(ans, t+le[d-(e+start-i)]); } } 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...