結果

問題 No.5 数字のブロック
ユーザー etheriqaetheriqa
提出日時 2014-12-22 07:08:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 344 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 163,288 KB
実行使用メモリ 394,240 KB
最終ジャッジ日時 2024-04-29 00:31:56
合計ジャッジ時間 4,738 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 128 ms
152,960 KB
testcase_04 AC 83 ms
100,864 KB
testcase_05 AC 218 ms
247,808 KB
testcase_06 AC 85 ms
106,624 KB
testcase_07 AC 60 ms
73,984 KB
testcase_08 AC 113 ms
135,552 KB
testcase_09 AC 14 ms
19,968 KB
testcase_10 AC 255 ms
292,480 KB
testcase_11 AC 57 ms
69,888 KB
testcase_12 AC 140 ms
164,864 KB
testcase_13 AC 212 ms
239,872 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 227 ms
260,480 KB
testcase_17 AC 308 ms
355,328 KB
testcase_18 AC 276 ms
311,808 KB
testcase_19 AC 344 ms
394,240 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 79 ms
98,304 KB
testcase_30 AC 20 ms
25,856 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if defined(__GNUG__) && !defined(__clang__)
#include <bits/stdc++.h>
#endif

#define inf(T) (numeric_limits<T>::min())
#define sup(T) (numeric_limits<T>::max())
#define rep(i,n) for (int i = 0; i < (n); i++)
#define asc(c) (c).begin(), (c).end()
#define desc(c) (c).rbegin(), (c).rend()
#define mp(...) make_pair(__VA_ARGS__)
#define mt(...) make_tuple(__VA_ARGS__)

using namespace std;

using ll = long long;
using ld = long double;

template <class Key>          using uset = unordered_set<Key>;
template <class Key, class T> using umap = unordered_map<Key, T>;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int l, n;
  cin >> l >> n;
  vector<int> ws(n);
  rep(i,n) cin >> ws[i];

  vector<vector<int>> dp(n + 1, vector<int>(n + 1, l + 1));
  rep(i, n) dp[i][0] = 0;
  rep(i, n) rep(j, i + 1) {
    dp[i + 1][j + 1] = min(dp[i][j + 1], dp[i][j] + ws[i]);
  }

  rep(i,n) {
    if (dp[n][n - i] <= l) {
      cout << n - i << endl;
      return 0;
    }
  }

  cout << 0 << endl;
  return 0;
}
0