# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
804325 | 2023-08-03T08:02:28 Z | 반딧불(#10100) | Fun Palace (CCO18_fun) | C++17 | 1 ms | 212 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, e; int a[1002], b[1002]; int DP[1002][12][12][2]; int main(){ scanf("%d %d", &n, &e); a[1] = e; for(int i=1; i<n; i++) scanf("%d %d", &b[i], &a[i+1]); b[n] = 1e8; int MX = 4; for(int i=0; i<=n+1; i++) for(int j=0; j<=MX; j++) for(int k=0; k<=MX; k++) DP[i][j][k][0] = DP[i][j][k][1] = -1; DP[n+1][0][MX][0] = 0; for(int i=n; i>=1; i--){ for(int j=0; j<=MX; j++){ for(int k=0; k<=MX; k++){ for(int l=0; l<2; l++){ if(DP[i+1][j][k][l] == -1) continue; for(int cnt=0; cnt<=MX; cnt++){ /// �� ĭ�� �ִ� ��� �� /// ���� ���ɼ��� �Ǻ��Ѵ�. k�� �̻� �� �� �ִ°�? �̰��� ������ �ּ� ������? int k2 = max(0, b[i]-cnt+!l); int l2 = (cnt + j >= a[i]); int j2 = max(0, cnt + k - a[i]); k2 = min(k2, MX), l2 = min(l2, MX), j2 = min(j2, MX); DP[i][j2][k2][l2] = max(DP[i][j2][k2][l2], DP[i][j][k][l] + cnt); } } } } } int ans = 0; for(int j=0; j<e; j++) for(int k=0; k<=MX; k++) ans = max(ans, DP[1][j][k][0]); printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |