Submission #00078


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
int w;
int n,k;
int nap[60];
int v[60];
int dp[60][20000][60];
int solve(int i,int J,int c){
if(dp[i][J][c]!=-1)return dp[i][J][c];
int rec;
if(i==n)return dp[i][J][c] = 0;
int a,b=0;
a=solve(i+1,J,c);
if(c<k && J>=nap[i])b=solve(i+1,J-nap[i],c+1)+v[i];
rec=max(a,b);
// cout<<c<<" "<<rec<<endl;
return dp[i][J][c]=rec;
}
int main(){
memset(dp,-1,sizeof(dp));
cin >> w;
cin >> n >>k;
for(int i=0;i<n;i++){
cin>>nap[i]>>v[i];
}
cout<<solve(0,w,0)<<endl;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
1.txt MLE 651 ms 262144 KB
1
2.txt MLE 512 ms 262144 KB
1
3.txt MLE 641 ms 262144 KB
1
s1.txt MLE 410 ms 262144 KB
1
s2.txt MLE 400 ms 262144 KB
1
s3.txt MLE 354 ms 262144 KB
1