Submission #241404

#TimeUsernameProblemLanguageResultExecution timeMemory
241404abacabaHoliday (IOI14_holiday)C++14
0 / 100
5096 ms1692 KiB
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <cstring> #include <chrono> #include <vector> #include "holiday.h" #include <map> #include <random> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define emb emplace_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), "r", stdin); } inline void setout(string s) { freopen(s.c_str(), "w", stdout); } template <typename T> void Min(T &a, T b) { a = min(a, b); } template <typename T> void Max(T &a, T b) { a = max(a, b); } const int inf = 0x3f3f3f3f; const int mod = 998244353; const int N = 1e5 + 15; int a[N]; inline ll get(int num, vector <int> now) { sort(now.rbegin(), now.rend()); if(num <= 0) return 0; ll sum = 0; for(int k = 0; k < min((int)now.size(), num); ++k) sum += now[k]; return sum; } long long findMaxAttraction(int n, int start, int d, int attraction[]) { for(int i = 0; i < n; ++i) a[i] = attraction[i]; ll ans = 0; for(int i = start; i < n; ++i) { vector <int> now = {}; for(int j = start; j <= i; ++j) now.pb(a[j]); Max(ans, get(d - (i - start), now)); for(int j = start - 1; j >= 0; --j) { now.pb(a[j]); Max(ans, get(d - (i - j) - (i - start), now)); } } 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...