# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
18152 | comet | 학교 설립 (IZhO13_school) | C++98 | 76 ms | 41172 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
int N,M,S;
ll d[501][101][101];
ll a[501],b[501];
ll f(int p,int x,int y){
if(p==N){
if(x<M||y<S)return -1e18;
return 0;
}
if(x==M&&y==S)return f(p+1,x,y);
if(x==M)return f(p+1,x,y+1)+b[y];
if(y==S)return f(p+1,x+1,y)+a[x];
ll& ret=d[p][x][y];
if(~ret)return ret;
return ret=max(f(p+1,x+1,y)+a[x],f(p+1,x,y+1)+b[y]);
}
int main(){
scanf("%d%d%d",&N,&M,&S);
for(int i=0;i<N;i++){
scanf("%lld%lld\n",&a[i],&b[i]);
}
memset(d,-1,sizeof(d));
printf("%lld\n",f(0,0,0));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |