結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2015-07-24 06:38:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,820 ms / 5,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 1,423 ms |
コンパイル使用メモリ | 157,544 KB |
実行使用メモリ | 394,624 KB |
最終ジャッジ日時 | 2024-07-08 12:49:27 |
合計ジャッジ時間 | 27,583 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,m,n) for(int i=m;i<n;i++) typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef vector<int> vec; typedef vector<vec> mat; static const double EPS = 1e-9; static const double PI = acos(-1.0); const int INF = 1e9; const int mod = 1e9 + 7; const int MAX = 10010; int dp[MAX][MAX] = {0}; int W[MAX]; int L, N; int rec(int l, int n){ if(l > L || n > N) return -1; if(dp[l][n] > 0){ return dp[l][n]; } int& res = dp[l][n]; res = max(rec(l, n+1), 1+rec(l+W[n], n+1)); return res; } int main(){ cin >> L >> N; rep(i, N) cin >> W[i]; cout << rec(0, 0) << endl; return 0; }