# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
391970 | 2021-04-20T09:09:58 Z | i_am_noob | Candies (JOI18_candies) | C++17 | 4537 ms | 7048 KB |
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma") #include<bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") using namespace std; #define rep(i,b,a) for(int i=(b); i<((int)(a)); i++) #define maxn 200005 signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); int n,a[maxn]; int_fast64_t dp[3][maxn]; cin >> n; rep(i,0,n) cin >> a[i]; dp[0][0]=dp[1][0]=0,dp[1][1]=a[0]; rep(i,1,n){ int x=(i+1)%3,y=(i+2)%3,z=i%3,l=1,r=i+2>>1,mid; dp[x][0]=0; if(dp[z][i+2>>1]>dp[y][i>>1]+a[i]){ rep(j,1,i+4>>1) dp[x][j]=dp[z][j]; continue; } while(l<r){ mid=l+r>>1; if(dp[z][mid]<=dp[y][mid-1]+a[i]) r=mid; else l=mid+1; } rep(j,1,l) dp[x][j]=dp[z][j]; rep(j,l,i+4>>1) dp[x][j]=dp[y][j-1]+a[i]; } rep(i,1,n+3>>1) cout << dp[n%3][i] << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 332 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 2 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 332 KB | Output is correct |
7 | Correct | 3 ms | 332 KB | Output is correct |
8 | Correct | 2 ms | 336 KB | Output is correct |
9 | Correct | 3 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 332 KB | Output is correct |
12 | Correct | 2 ms | 332 KB | Output is correct |
13 | Correct | 2 ms | 332 KB | Output is correct |
14 | Correct | 2 ms | 332 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 2 ms | 332 KB | Output is correct |
17 | Correct | 2 ms | 332 KB | Output is correct |
18 | Correct | 2 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 332 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
3 | Correct | 2 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 2 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 332 KB | Output is correct |
7 | Correct | 3 ms | 332 KB | Output is correct |
8 | Correct | 2 ms | 336 KB | Output is correct |
9 | Correct | 3 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 336 KB | Output is correct |
11 | Correct | 2 ms | 332 KB | Output is correct |
12 | Correct | 2 ms | 332 KB | Output is correct |
13 | Correct | 2 ms | 332 KB | Output is correct |
14 | Correct | 2 ms | 332 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 2 ms | 332 KB | Output is correct |
17 | Correct | 2 ms | 332 KB | Output is correct |
18 | Correct | 2 ms | 336 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 4456 ms | 7040 KB | Output is correct |
22 | Correct | 4458 ms | 6836 KB | Output is correct |
23 | Correct | 4509 ms | 7048 KB | Output is correct |
24 | Correct | 4537 ms | 6632 KB | Output is correct |
25 | Correct | 4457 ms | 6616 KB | Output is correct |
26 | Correct | 4453 ms | 6628 KB | Output is correct |
27 | Correct | 4472 ms | 6876 KB | Output is correct |
28 | Correct | 4455 ms | 6932 KB | Output is correct |
29 | Correct | 4478 ms | 6936 KB | Output is correct |
30 | Correct | 4533 ms | 6976 KB | Output is correct |
31 | Correct | 4449 ms | 7044 KB | Output is correct |
32 | Correct | 4354 ms | 6872 KB | Output is correct |
33 | Correct | 4528 ms | 6572 KB | Output is correct |
34 | Correct | 4397 ms | 6656 KB | Output is correct |
35 | Correct | 4405 ms | 6612 KB | Output is correct |
36 | Correct | 4389 ms | 6908 KB | Output is correct |
37 | Correct | 4462 ms | 7008 KB | Output is correct |
38 | Correct | 4436 ms | 6996 KB | Output is correct |
39 | Correct | 4400 ms | 6644 KB | Output is correct |
40 | Correct | 4418 ms | 6648 KB | Output is correct |
41 | Correct | 4446 ms | 6628 KB | Output is correct |
42 | Correct | 4446 ms | 6880 KB | Output is correct |
43 | Correct | 4449 ms | 7016 KB | Output is correct |
44 | Correct | 4473 ms | 6908 KB | Output is correct |
45 | Correct | 4388 ms | 6852 KB | Output is correct |
46 | Correct | 4513 ms | 6900 KB | Output is correct |
47 | Correct | 4401 ms | 7016 KB | Output is correct |
48 | Correct | 4514 ms | 6836 KB | Output is correct |
49 | Correct | 4465 ms | 6852 KB | Output is correct |
50 | Correct | 4387 ms | 6852 KB | Output is correct |