Submission #167017

#TimeUsernameProblemLanguageResultExecution timeMemory
167017davitmargHoliday (IOI14_holiday)C++17
23 / 100
49 ms6264 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() using namespace std; #ifndef death #include "holiday.h" #endif const int N = 100005; LL a[N], sum, ans; multiset<LL> s; LL findMaxAttraction(int n, int start, int d, int A[]) { for (int i = 0; i < n; i++) a[i] = A[i]; d++; for (int i = 0; i < n && i < d / 2; i++) { s.insert(a[i]); sum += a[i]; } int x = d / 2; d %= 2; ans = sum; for (int i = x; i < n; i++) { if (d) d--; else if (!s.empty()) { sum -= (*s.begin()); s.erase(s.begin()); } else break; if (!s.empty() && a[i] > (*s.begin())) { sum += a[i] - (*s.begin()); s.erase(s.begin()); s.insert(a[i]); } ans = max(ans, sum); } return ans; } #ifdef death int main() { int N, S, D, A[1002]; cin >> N >> S >> D; for (int i = 0; i < N; i++) cin >> A[i]; cout << findMaxAttraction(N, S, D, A) << endl; return 0; } #endif /* 5 0 7 10 2 20 1 40 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...