답안 #18152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18152 2016-01-25T01:05:15 Z comet 학교 설립 (IZhO13_school) C++
5 / 100
76 ms 41172 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 41016 KB Output isn't correct
2 Correct 0 ms 41016 KB Output is correct
3 Incorrect 4 ms 41016 KB Output isn't correct
4 Incorrect 0 ms 41016 KB Output isn't correct
5 Incorrect 5 ms 41016 KB Output isn't correct
6 Incorrect 0 ms 41016 KB Output isn't correct
7 Runtime error 10 ms 41012 KB SIGSEGV Segmentation fault
8 Runtime error 16 ms 41172 KB SIGSEGV Segmentation fault
9 Runtime error 3 ms 41160 KB SIGSEGV Segmentation fault
10 Runtime error 8 ms 41140 KB SIGSEGV Segmentation fault
11 Runtime error 5 ms 41012 KB SIGSEGV Segmentation fault
12 Runtime error 5 ms 41012 KB SIGSEGV Segmentation fault
13 Runtime error 9 ms 41012 KB SIGSEGV Segmentation fault
14 Runtime error 29 ms 41012 KB SIGSEGV Segmentation fault
15 Runtime error 44 ms 41012 KB SIGSEGV Segmentation fault
16 Runtime error 53 ms 41012 KB SIGSEGV Segmentation fault
17 Runtime error 61 ms 41012 KB SIGSEGV Segmentation fault
18 Runtime error 64 ms 41012 KB SIGSEGV Segmentation fault
19 Runtime error 69 ms 41012 KB SIGSEGV Segmentation fault
20 Runtime error 76 ms 41012 KB SIGSEGV Segmentation fault