# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
503468 |
2022-01-08T06:08:02 Z |
ymm |
Candies (JOI18_candies) |
C++17 |
|
4639 ms |
7116 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';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 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 |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 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 |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
4486 ms |
5556 KB |
Output is correct |
22 |
Correct |
4378 ms |
5496 KB |
Output is correct |
23 |
Correct |
4344 ms |
5456 KB |
Output is correct |
24 |
Correct |
4333 ms |
5416 KB |
Output is correct |
25 |
Correct |
4503 ms |
5404 KB |
Output is correct |
26 |
Correct |
4369 ms |
5852 KB |
Output is correct |
27 |
Correct |
4222 ms |
5556 KB |
Output is correct |
28 |
Correct |
4409 ms |
5552 KB |
Output is correct |
29 |
Correct |
4402 ms |
5672 KB |
Output is correct |
30 |
Correct |
4449 ms |
5596 KB |
Output is correct |
31 |
Correct |
4524 ms |
5448 KB |
Output is correct |
32 |
Correct |
4412 ms |
5620 KB |
Output is correct |
33 |
Correct |
4639 ms |
5420 KB |
Output is correct |
34 |
Correct |
4158 ms |
6068 KB |
Output is correct |
35 |
Correct |
4445 ms |
5424 KB |
Output is correct |
36 |
Correct |
4330 ms |
5724 KB |
Output is correct |
37 |
Correct |
4487 ms |
6948 KB |
Output is correct |
38 |
Correct |
4394 ms |
7116 KB |
Output is correct |
39 |
Correct |
4311 ms |
6724 KB |
Output is correct |
40 |
Correct |
4464 ms |
6912 KB |
Output is correct |
41 |
Correct |
4447 ms |
6768 KB |
Output is correct |
42 |
Correct |
4307 ms |
7092 KB |
Output is correct |
43 |
Correct |
4483 ms |
5876 KB |
Output is correct |
44 |
Correct |
4328 ms |
6952 KB |
Output is correct |
45 |
Correct |
4481 ms |
6848 KB |
Output is correct |
46 |
Correct |
4454 ms |
6840 KB |
Output is correct |
47 |
Correct |
4371 ms |
6896 KB |
Output is correct |
48 |
Correct |
4320 ms |
6680 KB |
Output is correct |
49 |
Correct |
4432 ms |
6744 KB |
Output is correct |
50 |
Correct |
4458 ms |
6624 KB |
Output is correct |