Submission #18157

# Submission time Handle Problem Language Result Execution time Memory
18157 2016-01-25T01:16:22 Z comet Schools (IZhO13_school) C++
25 / 100
3 ms 9132 KB
#include <cstdio>
#include <cstring>
#include <cassert>

using namespace std;
typedef long long ll;

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

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 0;
		return -1e9;
	}
	ll& ret=d[p][x][y];
	if(~ret)return ret;
	ret=f(p+1,x,y);
	if(x<M)ret=max(ret,f(p+1,x+1,y)+a[p]);
	if(y<S)ret=max(ret,f(p+1,x,y+1)+b[p]);
	return ret;
}

int main(){

	scanf("%d%d%d",&N,&M,&S);

	assert(N<=100);
	assert(M<=100);
	assert(S<=100);

	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 Correct 0 ms 9132 KB Output is correct
2 Correct 0 ms 9132 KB Output is correct
3 Correct 0 ms 9132 KB Output is correct
4 Correct 3 ms 9132 KB Output is correct
5 Correct 2 ms 9132 KB Output is correct
6 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
7 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
8 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
9 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
10 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
11 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
12 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
13 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
14 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
15 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
16 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
17 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
18 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
19 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)
20 Runtime error 0 ms 9132 KB gettid (syscall #186) was called by the program (disallowed syscall)