# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
120134 | KLPP | Two Dishes (JOI19_dishes) | C++14 | 650 ms | 151800 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<lld,lld> pii;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
#define INF 10000000000000000
lld n,m;
lld a[1000000];
lld b[1000000];
lld sa[1000000];
lld sb[1000000];
lld DP[2001][2001];
lld s[1000000];
lld t[1000000];
lld p[1000000];
lld q[1000000];
lld calc(int i, int j){
if(DP[i][j]!=-1)return DP[i][j];
DP[i][j]=-INF;
if(i>0){
if(sa[i]+sb[j]<=s[i-1])DP[i][j]=max(DP[i][j],calc(i-1,j)+p[i-1]);
else DP[i][j]=max(DP[i][j],calc(i-1,j));
}
if(j>0){
if(sa[i]+sb[j]<=t[j-1])DP[i][j]=max(DP[i][j],calc(i,j-1)+q[j-1]);
else DP[i][j]=max(DP[i][j],calc(i,j-1));
}
return DP[i][j];
}
int main(){
scanf("%lld %lld",&n,&m);
rep(i,0,n)scanf("%lld %lld %lld",&a[i],&s[i],&p[i]);
rep(i,0,m)scanf("%lld %lld %lld",&b[i],&t[i],&q[i]);
sa[0]=0;
sb[0]=0;
rep(i,1,n+1){
sa[i]=sa[i-1]+a[i-1];
}
rep(i,1,m+1){
sb[i]=sb[i-1]+b[i-1];
}
rep(i,0,n+1){
rep(j,0,m+1)DP[i][j]=-1;
}
DP[0][0]=0;
printf("%lld\n",calc(n,m));
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... |
# | 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... |