結果

問題 No.5 数字のブロック
ユーザー newlife171128newlife171128
提出日時 2019-05-10 06:08:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 144,468 KB
実行使用メモリ 394,660 KB
最終ジャッジ日時 2023-09-14 17:50:55
合計ジャッジ時間 10,369 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
394,400 KB
testcase_01 AC 170 ms
394,348 KB
testcase_02 WA -
testcase_03 AC 254 ms
394,460 KB
testcase_04 AC 175 ms
394,400 KB
testcase_05 WA -
testcase_06 AC 209 ms
394,348 KB
testcase_07 AC 227 ms
394,396 KB
testcase_08 AC 205 ms
394,332 KB
testcase_09 AC 184 ms
394,468 KB
testcase_10 AC 224 ms
394,336 KB
testcase_11 AC 186 ms
394,636 KB
testcase_12 AC 253 ms
394,400 KB
testcase_13 AC 222 ms
394,408 KB
testcase_14 AC 171 ms
394,344 KB
testcase_15 WA -
testcase_16 AC 242 ms
394,516 KB
testcase_17 AC 337 ms
394,388 KB
testcase_18 AC 211 ms
394,396 KB
testcase_19 AC 342 ms
394,336 KB
testcase_20 AC 132 ms
394,396 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 135 ms
394,336 KB
testcase_24 AC 135 ms
394,636 KB
testcase_25 AC 158 ms
394,412 KB
testcase_26 AC 196 ms
394,404 KB
testcase_27 AC 139 ms
394,524 KB
testcase_28 AC 150 ms
394,512 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 215 ms
394,644 KB
testcase_32 AC 249 ms
394,344 KB
testcase_33 AC 248 ms
394,456 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