Submission #594579

#TimeUsernameProblemLanguageResultExecution timeMemory
594579skittles1412Holiday (IOI14_holiday)C++17
7 / 100
5043 ms2344 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \ dbgh(__VA_ARGS__); #else #define dbg(...) #define cerr \ if (false) \ cerr #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) long solve(int start, int m, const vector<int>& arr) { long ans = 0; for (int i = 0; i <= m; i++) { for (int j = 0; i * 2 + j <= m; j++) { vector<int> cur(arr.begin() + max(0, start - j), arr.begin() + min(sz(arr), start + i + 1)); sort(begin(cur), end(cur), greater<>()); ans = max(ans, accumulate(cur.begin(), cur.begin() + min(sz(cur), m - i * 2 - j), long(0))); } } return ans; } long findMaxAttraction(int n, int start, int m, int inarr[]) { vector<int> arr(inarr, inarr + n); long ans = solve(start, m, arr); reverse(begin(arr), end(arr)); ans = max(ans, solve(n - start - 1, m, arr)); 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...