結果

問題 No.5 数字のブロック
ユーザー lam6er
提出日時 2025-03-20 20:15:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 198,868 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-20 20:16:37
合計ジャッジ時間 2,789 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (auto& i : a) cin >> i;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    k -= a[i];
    if (k < 0) {
      cout << i << '\n';
      return 0;
    }
  }
  cout << n << "\n";
  return 0;
}
0