답안 #503479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503479 2022-01-08T07:11:07 Z ymm Candies (JOI18_candies) C++17
100 / 100
4284 ms 5628 KB
///
///   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';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 4128 ms 5584 KB Output is correct
22 Correct 4268 ms 5524 KB Output is correct
23 Correct 4284 ms 5576 KB Output is correct
24 Correct 4175 ms 5476 KB Output is correct
25 Correct 4074 ms 5448 KB Output is correct
26 Correct 4203 ms 5396 KB Output is correct
27 Correct 4159 ms 5540 KB Output is correct
28 Correct 4225 ms 5496 KB Output is correct
29 Correct 4182 ms 5564 KB Output is correct
30 Correct 3913 ms 5396 KB Output is correct
31 Correct 4078 ms 5356 KB Output is correct
32 Correct 4166 ms 5628 KB Output is correct
33 Correct 4075 ms 5456 KB Output is correct
34 Correct 4061 ms 5396 KB Output is correct
35 Correct 4165 ms 5496 KB Output is correct
36 Correct 4102 ms 5568 KB Output is correct
37 Correct 4224 ms 5176 KB Output is correct
38 Correct 3939 ms 5212 KB Output is correct
39 Correct 4118 ms 5120 KB Output is correct
40 Correct 3786 ms 5124 KB Output is correct
41 Correct 4097 ms 5112 KB Output is correct
42 Correct 4109 ms 5220 KB Output is correct
43 Correct 3939 ms 5384 KB Output is correct
44 Correct 4096 ms 5212 KB Output is correct
45 Correct 4159 ms 5096 KB Output is correct
46 Correct 3955 ms 5212 KB Output is correct
47 Correct 4058 ms 5508 KB Output is correct
48 Correct 4062 ms 5128 KB Output is correct
49 Correct 4018 ms 5224 KB Output is correct
50 Correct 4119 ms 5208 KB Output is correct