結果

問題 No.5 数字のブロック
ユーザー newlife171128newlife171128
提出日時 2019-05-10 06:14:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 307 ms / 5,000 ms
コード長 866 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 144,436 KB
実行使用メモリ 394,632 KB
最終ジャッジ日時 2023-09-14 17:51:32
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
394,348 KB
testcase_01 AC 131 ms
394,400 KB
testcase_02 AC 131 ms
394,528 KB
testcase_03 AC 214 ms
394,624 KB
testcase_04 AC 133 ms
394,620 KB
testcase_05 AC 236 ms
394,408 KB
testcase_06 AC 169 ms
394,392 KB
testcase_07 AC 187 ms
394,520 KB
testcase_08 AC 165 ms
394,400 KB
testcase_09 AC 144 ms
394,520 KB
testcase_10 AC 186 ms
394,528 KB
testcase_11 AC 147 ms
394,400 KB
testcase_12 AC 215 ms
394,632 KB
testcase_13 AC 184 ms
394,340 KB
testcase_14 AC 133 ms
394,496 KB
testcase_15 AC 133 ms
394,344 KB
testcase_16 AC 222 ms
394,348 KB
testcase_17 AC 272 ms
394,468 KB
testcase_18 AC 208 ms
394,456 KB
testcase_19 AC 307 ms
394,340 KB
testcase_20 AC 132 ms
394,628 KB
testcase_21 AC 132 ms
394,388 KB
testcase_22 AC 133 ms
394,524 KB
testcase_23 AC 131 ms
394,404 KB
testcase_24 AC 136 ms
394,520 KB
testcase_25 AC 140 ms
394,564 KB
testcase_26 AC 129 ms
394,464 KB
testcase_27 AC 129 ms
394,408 KB
testcase_28 AC 131 ms
394,332 KB
testcase_29 AC 135 ms
394,508 KB
testcase_30 AC 137 ms
394,492 KB
testcase_31 AC 131 ms
394,512 KB
testcase_32 AC 132 ms
394,520 KB
testcase_33 AC 132 ms
394,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

const long long INF = 1LL << 60;
#define MOD 1000000007;

typedef long long ll;

#define writeln(n) cout<<n<<endl;
#define rep(i,n) for(int i=0; i<n; i++);

typedef pair<float, float> P;

typedef pair<string, int> Psi;

int d[10010][10010];
int main() {


	int l;
	cin>>l;

	int n;
	cin>>n;

	for(int i=0; i<=10000; i++){
		for(int j=0; j<=10000; j++){
			d[i][j] =-1;
		}
	}

	d[0][0] =0;

	for(int i=1; i<=n; i++){

		int tmp ;
		cin>>tmp;

		for(int j=0; j<=l; j++){




			if(d[i-1][j] !=-1){

				d[i][j] = max(d[i][j],d[i-1][j]);
			if(j+tmp<=l){


				d[i][j+tmp] = max(d[i][j+tmp],d[i-1][j]+1);


			}

			}

		}
	}

/*	for(int i=0; i<=n; i++){
		for(int j=0; j<=l; j++){
		cout<<j<<":"<<d[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int ans =0;
	for(int i=0; i<=l; i++){
		ans = max(ans,d[n][i]);
	}
	writeln(ans);

}

0