# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
18154 |
2016-01-25T01:08:43 Z |
comet |
Schools (IZhO13_school) |
C++ |
|
85 ms |
41016 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;
}
ll& ret=d[p][x][y];
if(~ret)return ret;
if(x==M&&y==S)return ret=f(p+1,x,y);
if(x==M)return ret=max(f(p+1,x,y),f(p+1,x,y+1)+b[y]);
if(y==S)return ret=max(f(p+1,x,y),f(p+1,x+1,y)+a[x]);
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 |
5 ms |
41016 KB |
Output is correct |
3 |
Incorrect |
6 ms |
41016 KB |
Output isn't correct |
4 |
Incorrect |
7 ms |
41016 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
41016 KB |
Output isn't correct |
6 |
Incorrect |
13 ms |
41016 KB |
Output isn't correct |
7 |
Runtime error |
3 ms |
41012 KB |
SIGSEGV Segmentation fault |
8 |
Runtime error |
0 ms |
41012 KB |
SIGSEGV Segmentation fault |
9 |
Runtime error |
5 ms |
41012 KB |
SIGSEGV Segmentation fault |
10 |
Runtime error |
3 ms |
41012 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 |
15 ms |
41012 KB |
SIGSEGV Segmentation fault |
14 |
Runtime error |
17 ms |
41012 KB |
SIGSEGV Segmentation fault |
15 |
Runtime error |
43 ms |
41012 KB |
SIGSEGV Segmentation fault |
16 |
Runtime error |
47 ms |
41012 KB |
SIGSEGV Segmentation fault |
17 |
Runtime error |
58 ms |
41012 KB |
SIGSEGV Segmentation fault |
18 |
Runtime error |
63 ms |
41012 KB |
SIGSEGV Segmentation fault |
19 |
Runtime error |
70 ms |
41012 KB |
SIGSEGV Segmentation fault |
20 |
Runtime error |
85 ms |
41012 KB |
SIGSEGV Segmentation fault |