結果

問題 No.5 数字のブロック
ユーザー めうめう🎒めうめう🎒
提出日時 2016-01-16 11:06:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,377 ms / 5,000 ms
コード長 799 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 72,776 KB
実行使用メモリ 395,392 KB
最終ジャッジ日時 2024-04-29 06:53:55
合計ジャッジ時間 33,597 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 308 ms
394,752 KB
testcase_01 AC 375 ms
394,624 KB
testcase_02 AC 305 ms
394,752 KB
testcase_03 AC 1,988 ms
395,136 KB
testcase_04 AC 301 ms
395,136 KB
testcase_05 AC 2,377 ms
395,264 KB
testcase_06 AC 957 ms
395,136 KB
testcase_07 AC 1,315 ms
395,008 KB
testcase_08 AC 857 ms
395,136 KB
testcase_09 AC 452 ms
394,880 KB
testcase_10 AC 1,222 ms
395,264 KB
testcase_11 AC 472 ms
395,008 KB
testcase_12 AC 1,930 ms
395,136 KB
testcase_13 AC 1,244 ms
395,264 KB
testcase_14 AC 312 ms
394,752 KB
testcase_15 AC 297 ms
394,624 KB
testcase_16 AC 2,027 ms
395,264 KB
testcase_17 AC 3,334 ms
395,392 KB
testcase_18 AC 1,835 ms
395,392 KB
testcase_19 AC 4,377 ms
395,392 KB
testcase_20 AC 298 ms
394,752 KB
testcase_21 AC 302 ms
394,624 KB
testcase_22 AC 296 ms
394,752 KB
testcase_23 AC 293 ms
394,752 KB
testcase_24 AC 297 ms
394,624 KB
testcase_25 AC 383 ms
394,624 KB
testcase_26 AC 300 ms
394,624 KB
testcase_27 AC 298 ms
394,752 KB
testcase_28 AC 294 ms
394,752 KB
testcase_29 AC 306 ms
395,008 KB
testcase_30 AC 330 ms
394,880 KB
testcase_31 AC 296 ms
394,752 KB
testcase_32 AC 293 ms
394,752 KB
testcase_33 AC 296 ms
394,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <vector>
using namespace std;

#define INF (1 << 30)
#define INFLL (1LL << 60)

int l,n,w[10001];
int memo[10010][10010];

int saiki(int nokori,int now){
	if(memo[nokori][now] != INF) return memo[nokori][now];
	if(now == n) return 0;
	int a = 0,b = 0;
	if(nokori - w[now] >= 0) a += saiki(nokori - w[now],now + 1) + 1;
	b += saiki(nokori,now + 1);
	return memo[nokori][now] = max(a,b);
}

int main() {
	for(int i = 0;i < 10010;i++){
		for(int j = 0;j < 10010;j++){
			memo[i][j] = INF;
		}
	}
	cin >> l >> n;
	for(int i = 0;i < n;i++){
		cin >> w[i];
	}
	cout << saiki(l,0) << endl;
	return 0;
}
0