# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
580349 | 2022-06-21T06:19:47 Z | 반딧불(#8355) | Uplifting Excursion (BOI22_vault) | C++17 | 2146 ms | 16292 KB |
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; const int LIM = 505000; const int LIM2 = LIM+LIM; void imp(){ puts("impossible"); exit(0); } int n, k; int arr[702]; int DP[2][LIM2+2]; int dq1[LIM2+2]; int dq2[LIM2+2]; int fr, sz; int main(){ scanf("%d %d", &n, &k); for(int i=0; i<=n+n; i++) scanf("%d", &arr[i]); if(k<=-LIM || k>=LIM) imp(); for(int i=0; i<=LIM2; i++) DP[0][i] = DP[1][i] = -1e9; DP[1][LIM] = 0; for(int i=0; i<=n+n; i++){ /// ����ġ: i+n int b = i%2; if(i>n){ /// ���� ����ġ int ri = i-n; for(int s=0; s<ri; s++){ fr=sz=0; for(int j=s, p=0; j<=LIM2; j+=ri, p++){ DP[b][j] = max(DP[b][j], DP[!b][j]); while(fr!=sz && dq2[fr] < p) fr++; int nf = DP[!b][j]-p; while(fr!=sz && dq1[sz-1] < nf) sz--; dq1[sz] = nf; dq2[sz++] = p+arr[i]; DP[b][j] = max(DP[b][j], dq1[fr] + p); } } } else if(i==n){ for(int j=0; j<=LIM2; j++) DP[b][j] = max(DP[b][j], DP[!b][j]) + arr[i]; } else{ int ri = n-i; for(int s=0; s<ri; s++){ fr=sz=0; for(int j=LIM2-s, p=0; j>=0; j-=ri, p++){ DP[b][j] = max(DP[b][j], DP[!b][j]); while(fr!=sz && dq2[fr] < p) fr++; int nf = DP[!b][j]-p; while(fr!=sz && dq1[sz-1] < nf) sz--; dq1[sz] = nf; dq2[sz++] = p+arr[i]; DP[b][j] = max(DP[b][j], dq1[fr] + p); } } } } if(DP[0][LIM+k] <= 0) imp(); printf("%d", DP[0][LIM+k]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16084 KB | Output is correct |
2 | Correct | 32 ms | 16104 KB | Output is correct |
3 | Correct | 17 ms | 16112 KB | Output is correct |
4 | Correct | 109 ms | 15988 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 993 ms | 16068 KB | Output is correct |
7 | Correct | 947 ms | 16204 KB | Output is correct |
8 | Correct | 954 ms | 16100 KB | Output is correct |
9 | Correct | 872 ms | 15992 KB | Output is correct |
10 | Correct | 882 ms | 16072 KB | Output is correct |
11 | Correct | 818 ms | 15996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16084 KB | Output is correct |
2 | Correct | 32 ms | 16104 KB | Output is correct |
3 | Correct | 17 ms | 16112 KB | Output is correct |
4 | Correct | 109 ms | 15988 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 993 ms | 16068 KB | Output is correct |
7 | Correct | 947 ms | 16204 KB | Output is correct |
8 | Correct | 954 ms | 16100 KB | Output is correct |
9 | Correct | 872 ms | 15992 KB | Output is correct |
10 | Correct | 882 ms | 16072 KB | Output is correct |
11 | Correct | 818 ms | 15996 KB | Output is correct |
12 | Correct | 28 ms | 16084 KB | Output is correct |
13 | Correct | 34 ms | 16088 KB | Output is correct |
14 | Correct | 18 ms | 16056 KB | Output is correct |
15 | Correct | 109 ms | 16096 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 960 ms | 16088 KB | Output is correct |
18 | Correct | 884 ms | 16048 KB | Output is correct |
19 | Correct | 964 ms | 16088 KB | Output is correct |
20 | Correct | 1033 ms | 16168 KB | Output is correct |
21 | Correct | 832 ms | 16292 KB | Output is correct |
22 | Correct | 900 ms | 16064 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 2105 ms | 16088 KB | Output is correct |
25 | Correct | 1818 ms | 16044 KB | Output is correct |
26 | Correct | 2146 ms | 16076 KB | Output is correct |
27 | Correct | 2090 ms | 16092 KB | Output is correct |
28 | Correct | 1782 ms | 16156 KB | Output is correct |
29 | Correct | 1732 ms | 16172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 16008 KB | Output is correct |
2 | Incorrect | 1 ms | 284 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 16008 KB | Output is correct |
2 | Incorrect | 1 ms | 284 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 16008 KB | Output is correct |
2 | Incorrect | 1 ms | 284 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16084 KB | Output is correct |
2 | Correct | 32 ms | 16104 KB | Output is correct |
3 | Correct | 17 ms | 16112 KB | Output is correct |
4 | Correct | 109 ms | 15988 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 993 ms | 16068 KB | Output is correct |
7 | Correct | 947 ms | 16204 KB | Output is correct |
8 | Correct | 954 ms | 16100 KB | Output is correct |
9 | Correct | 872 ms | 15992 KB | Output is correct |
10 | Correct | 882 ms | 16072 KB | Output is correct |
11 | Correct | 818 ms | 15996 KB | Output is correct |
12 | Correct | 130 ms | 16008 KB | Output is correct |
13 | Incorrect | 1 ms | 284 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 16008 KB | Output is correct |
2 | Incorrect | 1 ms | 284 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16084 KB | Output is correct |
2 | Correct | 32 ms | 16104 KB | Output is correct |
3 | Correct | 17 ms | 16112 KB | Output is correct |
4 | Correct | 109 ms | 15988 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 993 ms | 16068 KB | Output is correct |
7 | Correct | 947 ms | 16204 KB | Output is correct |
8 | Correct | 954 ms | 16100 KB | Output is correct |
9 | Correct | 872 ms | 15992 KB | Output is correct |
10 | Correct | 882 ms | 16072 KB | Output is correct |
11 | Correct | 818 ms | 15996 KB | Output is correct |
12 | Correct | 28 ms | 16084 KB | Output is correct |
13 | Correct | 34 ms | 16088 KB | Output is correct |
14 | Correct | 18 ms | 16056 KB | Output is correct |
15 | Correct | 109 ms | 16096 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 960 ms | 16088 KB | Output is correct |
18 | Correct | 884 ms | 16048 KB | Output is correct |
19 | Correct | 964 ms | 16088 KB | Output is correct |
20 | Correct | 1033 ms | 16168 KB | Output is correct |
21 | Correct | 832 ms | 16292 KB | Output is correct |
22 | Correct | 900 ms | 16064 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 2105 ms | 16088 KB | Output is correct |
25 | Correct | 1818 ms | 16044 KB | Output is correct |
26 | Correct | 2146 ms | 16076 KB | Output is correct |
27 | Correct | 2090 ms | 16092 KB | Output is correct |
28 | Correct | 1782 ms | 16156 KB | Output is correct |
29 | Correct | 1732 ms | 16172 KB | Output is correct |
30 | Correct | 130 ms | 16008 KB | Output is correct |
31 | Incorrect | 1 ms | 284 KB | Output isn't correct |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 16008 KB | Output is correct |
2 | Incorrect | 1 ms | 284 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16084 KB | Output is correct |
2 | Correct | 32 ms | 16104 KB | Output is correct |
3 | Correct | 17 ms | 16112 KB | Output is correct |
4 | Correct | 109 ms | 15988 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 993 ms | 16068 KB | Output is correct |
7 | Correct | 947 ms | 16204 KB | Output is correct |
8 | Correct | 954 ms | 16100 KB | Output is correct |
9 | Correct | 872 ms | 15992 KB | Output is correct |
10 | Correct | 882 ms | 16072 KB | Output is correct |
11 | Correct | 818 ms | 15996 KB | Output is correct |
12 | Correct | 28 ms | 16084 KB | Output is correct |
13 | Correct | 34 ms | 16088 KB | Output is correct |
14 | Correct | 18 ms | 16056 KB | Output is correct |
15 | Correct | 109 ms | 16096 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 960 ms | 16088 KB | Output is correct |
18 | Correct | 884 ms | 16048 KB | Output is correct |
19 | Correct | 964 ms | 16088 KB | Output is correct |
20 | Correct | 1033 ms | 16168 KB | Output is correct |
21 | Correct | 832 ms | 16292 KB | Output is correct |
22 | Correct | 900 ms | 16064 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 2105 ms | 16088 KB | Output is correct |
25 | Correct | 1818 ms | 16044 KB | Output is correct |
26 | Correct | 2146 ms | 16076 KB | Output is correct |
27 | Correct | 2090 ms | 16092 KB | Output is correct |
28 | Correct | 1782 ms | 16156 KB | Output is correct |
29 | Correct | 1732 ms | 16172 KB | Output is correct |
30 | Correct | 130 ms | 16008 KB | Output is correct |
31 | Incorrect | 1 ms | 284 KB | Output isn't correct |
32 | Halted | 0 ms | 0 KB | - |