Submission #18153

# Submission time Handle Problem Language Result Execution time Memory
18153 2016-01-25T01:06:43 Z comet Schools (IZhO13_school) C++
5 / 100
79 ms 41168 KB
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long ll;

int N,M,S;
ll d[501][101][101];
ll a[501],b[501];

ll max(ll x,ll y){
	return x>y?x:y;
}

ll max(ll x,ll y,ll z){
	return max(x,max(y,z));
}

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,y),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
1 Incorrect 4 ms 41016 KB Output isn't correct
2 Correct 0 ms 41016 KB Output is correct
3 Incorrect 3 ms 41016 KB Output isn't correct
4 Incorrect 4 ms 41016 KB Output isn't correct
5 Incorrect 5 ms 41016 KB Output isn't correct
6 Incorrect 16 ms 41016 KB Output isn't correct
7 Runtime error 10 ms 41012 KB SIGSEGV Segmentation fault
8 Runtime error 19 ms 41168 KB SIGSEGV Segmentation fault
9 Runtime error 6 ms 41156 KB SIGSEGV Segmentation fault
10 Runtime error 13 ms 41144 KB SIGSEGV Segmentation fault
11 Runtime error 5 ms 41012 KB SIGSEGV Segmentation fault
12 Runtime error 0 ms 41012 KB SIGSEGV Segmentation fault
13 Runtime error 11 ms 41012 KB SIGSEGV Segmentation fault
14 Runtime error 17 ms 41012 KB SIGSEGV Segmentation fault
15 Runtime error 53 ms 41012 KB SIGSEGV Segmentation fault
16 Runtime error 45 ms 41012 KB SIGSEGV Segmentation fault
17 Runtime error 58 ms 41012 KB SIGSEGV Segmentation fault
18 Runtime error 57 ms 41012 KB SIGSEGV Segmentation fault
19 Runtime error 61 ms 41012 KB SIGSEGV Segmentation fault
20 Runtime error 79 ms 41012 KB SIGSEGV Segmentation fault