# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
809127 | 2023-08-05T18:03:23 Z | urd05 | Fun Palace (CCO18_fun) | C++17 | 62 ms | 82772 KB |
#include <bits/stdc++.h> using namespace std; int n; int e; int a[1000]; int b[1000]; int dp[1000][50001]; //정확히. const int MAX=20000; int main() { scanf("%d\n%d\n",&n,&e); for(int i=0;i<n-1;i++) { scanf("%d %d",&a[i],&b[i]); } for(int i=0;i<=MAX;i++) { dp[n-1][i]=i; } for(int i=n-2;i>=0;i--) { int mx=0; for(int j=0;j<b[i];j++) { mx=max(mx,dp[i+1][j]); } for(int j=0;j<=MAX;j++) { if (j<a[i]) { dp[i][j]=max(mx+j,dp[i+1][b[i]+j]); } else if (j<a[i]+b[i]) { dp[i][j]=dp[i+1][j-a[i]]+a[i]; } else { dp[i][j]=dp[i+1][j]; } } } int ret=0; for(int i=0;i<e;i++) { ret=max(ret,dp[0][i]); } printf("%d",ret); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 0 ms | 468 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 54 ms | 82732 KB | Output is correct |
8 | Correct | 62 ms | 81216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 0 ms | 468 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 1 ms | 852 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 12 ms | 16764 KB | Output is correct |
15 | Correct | 12 ms | 16212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 468 KB | Output is correct |
3 | Correct | 1 ms | 468 KB | Output is correct |
4 | Correct | 0 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 0 ms | 468 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 468 KB | Output is correct |
12 | Correct | 1 ms | 468 KB | Output is correct |
13 | Correct | 1 ms | 596 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 54 ms | 82732 KB | Output is correct |
17 | Correct | 62 ms | 81216 KB | Output is correct |
18 | Correct | 0 ms | 468 KB | Output is correct |
19 | Correct | 1 ms | 468 KB | Output is correct |
20 | Correct | 1 ms | 852 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 12 ms | 16764 KB | Output is correct |
23 | Correct | 12 ms | 16212 KB | Output is correct |
24 | Correct | 43 ms | 82708 KB | Output is correct |
25 | Correct | 43 ms | 81168 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 57 ms | 82760 KB | Output is correct |
28 | Correct | 59 ms | 82772 KB | Output is correct |
29 | Correct | 55 ms | 80620 KB | Output is correct |
30 | Correct | 40 ms | 57192 KB | Output is correct |