This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
/// What would happen if we used assembly language for CP?
/// Sorry, that was a strange thing to ask.
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")
#define max(x,y) ((x)>(y)?(x):(y))
const int N = 200'010;
double dp[3][N];
int a[N];
int n;
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
Loop(i,0,n) cin >> a[i];
Loop(_,0,n)
{
const double x = a[_];
const int i = (_+1)%3;
const int r = (_+2)/2;
switch(i){
case 0:
Loop(j,1,r)
dp[0][j] = max(dp[2][j], dp[1][j-1]+x);
break;
case 1:
Loop(j,1,r)
dp[1][j] = max(dp[0][j], dp[2][j-1]+x);
break;
case 2:
Loop(j,1,r)
dp[2][j] = max(dp[1][j], dp[0][j-1]+x);
break;
}
dp[i][0] = max(dp[(i+2)%3][0], x);
}
Loop(i,0,(n+1)/2) cout << (ll)dp[n%3][i] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |