結果

問題 No.5 数字のブロック
ユーザー a01sa01to
提出日時 2023-05-21 16:03:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 1,915 ms
コンパイル使用メモリ 198,220 KB
最終ジャッジ日時 2025-02-13 03:57:51
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int l, n;
  cin >> l >> n;
  vector<int> w(n);
  rep(i, n) cin >> w[i];
  sort(w.begin(), w.end());
  int ans = 0;
  rep(i, n) {
    if (l >= w[i]) {
      l -= w[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
0