Submission #1007727

#TimeUsernameProblemLanguageResultExecution timeMemory
1007727onbertHoliday (IOI14_holiday)C++17
0 / 100
5066 ms3788 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; #define int long long int findMaxAttraction(int32_t n, int32_t S, int32_t d, int32_t a[]) { int l = 0, r = S; int ans = 0; while (l <= S && r<n) { int k = min(d - (r-l) - min(S-l, r-S), r-l+1); // cout << l << " " << r << " " << k << endl; vector<pair<int,int>> v; for (int i=l;i<=r;i++) v.push_back({a[i], i}); sort(v.rbegin(), v.rend()); int curans = 0, leftmost = 1e9; for (int i=0;i<k;i++) { curans += v[i].first; leftmost = min(v[i].second, leftmost); } // cout << l << " " << r << " " << curans << " " << leftmost << endl; ans = max(curans, ans); if (l==leftmost || l==S) r++; else l++; } 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...