Submission #421738

#TimeUsernameProblemLanguageResultExecution timeMemory
421738vulpes2Candies (JOI18_candies)C++17
8 / 100
255 ms524292 KiB
//#include <atcoder/maxflow.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #include <iostream> #include <map> #include <list> #include <set> #include <algorithm> #include <vector> #include <string> #include <functional> #include <queue> #include <deque> #include <stack> #include <unordered_map> #include <unordered_set> #include <cmath> #include <iterator> #include <random> #include <chrono> #include <complex> #include <bitset> #include <fstream> #define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i) #define set_map_includes(set, elt) (set.find((elt)) != set.end()) #define readint(i) int i; cin >> i #define readll(i) ll i; cin >> i #define readdouble(i) double i; cin >> i #define readstring(s) string s; cin >> s typedef long long ll; //using namespace __gnu_pbds; //using namespace atcoder; using namespace std; const ll modd = (1000LL * 1000LL * 1000LL + 7LL); //const ll modd = 998244353; int main(int argc, char *argv[]) { mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int> rand_gen(0, modd); // rand_gen(rng) gets the rand no ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(12); // readint(test_cases); int test_cases = 1; forr(t, 1, test_cases) { readint(n); vector<ll> a(n+1); forr(i,1,n) { readint(aa); a[i] = aa; } vector<vector<ll>> maxp(n+1, vector<ll>(n+1, -modd*modd)), maxn(n+1, vector<ll>(n+1, -modd*modd)); maxn[0][0] = 0; forr(i,1,n) { maxn[i][0] = 0; forr(j,1,n-1) { maxp[i][j] = a[i]+maxn[i-1][j-1]; maxn[i][j] = max(maxp[i-1][j], maxn[i-1][j]); } } forr(i,1,n) { cout << max(maxp[n][i], maxn[n][i]) << endl; if (2*i+1>n) break; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...