Submission #19180

#TimeUsernameProblemLanguageResultExecution timeMemory
19180tncks0121달리는 게임 (kriii3_E)C++14
26 / 70
1000 ms32348 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> #include <functional> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; typedef pair<ll, int> pli; #define debug(format, ...) printf(format, __VA_ARGS__); const int N_ = 1000500; int N; ll A[N_]; ll S1[N_], S2[N_]; ll cost (int l, int r) { return (S2[r] - S2[l-1]) - (S1[r] - S1[l-1]) * (l-1); } struct line { ll a, b; line (ll a = 0, ll b = 0): a(a), b(b) { } ll y (ll x) { return a * x + b; } }; struct CHT { vector<line> stk; void add (line p) { } } cht; ll tb[N_]; int main() { scanf("%d", &N); for(int i = 1; i <= N; i++) { scanf("%lld", A+i); S1[i] = S1[i-1] + A[i]; S2[i] = S2[i-1] + i * A[i]; } for(int i = 1; i <= N; i++) { tb[i] = tb[i-1]; for(int j = 0; j < i; j++) { ll val = tb[j] + S2[i] - (S1[i]) * j + (-S2[j] + S1[j] * j); tb[i] = max(tb[i], val); } } printf("%lld\n", tb[N]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...