結果

問題 No.527 ナップサック容量問題
ユーザー amtgjwamtgjw
提出日時 2018-05-16 12:46:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 805 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 66,832 KB
実行使用メモリ 43,908 KB
最終ジャッジ日時 2023-09-10 22:18:28
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,516 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 4 ms
4,960 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 24 ms
31,788 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 29 ms
37,820 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 12 ms
17,564 KB
testcase_15 AC 19 ms
23,440 KB
testcase_16 AC 3 ms
4,940 KB
testcase_17 AC 16 ms
21,408 KB
testcase_18 AC 17 ms
23,436 KB
testcase_19 AC 4 ms
7,040 KB
testcase_20 AC 13 ms
17,388 KB
testcase_21 AC 33 ms
43,900 KB
testcase_22 AC 23 ms
29,572 KB
testcase_23 AC 32 ms
41,908 KB
testcase_24 AC 9 ms
11,120 KB
testcase_25 WA -
testcase_26 AC 21 ms
27,572 KB
testcase_27 AC 21 ms
27,520 KB
testcase_28 WA -
testcase_29 AC 34 ms
43,908 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 19 ms
25,584 KB
testcase_33 AC 16 ms
21,424 KB
testcase_34 WA -
testcase_35 AC 19 ms
25,476 KB
testcase_36 WA -
testcase_37 AC 15 ms
19,340 KB
testcase_38 AC 18 ms
23,732 KB
testcase_39 AC 17 ms
23,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000007

#define MAX 		105

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

int DP[MAX][100005];

int main(){
	int N;cin>>N;

	vector<int> V(N);
	vector<int> W(N);
	REP(i,N){cin>>V[i]>>W[i];}
	int maxV;cin>>maxV;

	REPS(i,1,N+1){
		REPS(j,1,100001){
			if(j-W[i-1]<0){
				DP[i][j]=DP[i-1][j];
				continue;
			}
			DP[i][j] = max(DP[i-1][j],DP[i-1][j-W[i-1]]+V[i-1]);
		}
	}

	int k=0;
	while(DP[N][k++]!=maxV);
	cout << (k-1) << endl;
	while(DP[N][++k]==maxV);
	cout << (k-1) << endl;
	
	return 0;
}
0