# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
806325 | urd05 | Fun Palace (CCO18_fun) | C++17 | 154 ms | 78620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
int e;
int a[1000];
int b[1000];
int dp[1000][20001];
int temp[20001];
const int MAX=20000;
int nt[20005];
int main() {
scanf("%d%d",&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;
nt[i]=-1;
}
for(int i=n-2;i>=0;i--) {
temp[b[i]]=dp[i+1][b[i]]-b[i];
for(int j=b[i]+1;j<=MAX;j++) {
temp[j]=max(temp[j-1],dp[i+1][j]-j);
}
for(int j=0;j<=MAX;j++) {
if (j>0) {
dp[i][j]=max(dp[i][j],dp[i][j-1]);
}
dp[i][j]=max(dp[i][j],dp[i+1][j]);
int now=0;
if (j<a[i]) {
now=dp[i+1][b[i]]+j;
}
else if (j<a[i]+b[i]) {
now=dp[i+1][j-a[i]]+a[i];
}
else {
now=dp[i+1][j];
}
dp[i][j]=max(dp[i][j],now);
}
for(int j=0;j<a[i]+b[i];j++) {
nt[j]=i;
}
}
printf("%d",dp[0][e-1]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |