Submission #00076


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
int W;
int N,K;
int a[100];
int b[100];
int mem[50][10000][50];
int solve(int idx,int w,int k){
if(idx == N){
return 0;
}
if(mem[idx][w][k] != -1){
return mem[idx][w][k];
}
int ret=-1;
if(w - a[idx] >= 0 && k != 0){
ret = max(ret,max(solve(idx+1,w-a[idx],k-1) + b[idx],solve(idx+1,w,k)));
}else{
ret = max(ret,solve(idx+1,w,k));
}
return mem[idx][w][k] = ret;
}
int main(){
cin>>W;
cin>>N>>K;
for(int i=0;i<N;i++){
cin>>a[i]>>b[i];
}
memset(mem,-1,sizeof(mem));
cout<<solve(0,W,K)<<endl;
}

ステータス

項目 データ
問題 0004 - 「とっぴー」カウンセリング
ユーザー名 ei1417
投稿日時 2016-04-27 17:23:42
言語 C++11
状態 Wrong Answer
得点 0
ソースコード長 946 Byte
最大実行時間 851 ms
最大メモリ使用量 9656 KB

セット

セット 得点 Cases
1 ALL 0 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.txt AC 33 ms 98140 KB
1
2.txt AC 56 ms 98120 KB
1
3.txt AC 133 ms 98108 KB
1
s1.txt AC 25 ms 98224 KB
1
s2.txt AC 25 ms 98080 KB
1
s3.txt AC 25 ms 98064 KB
1