結果

問題 No.5 数字のブロック
ユーザー wightou
提出日時 2025-04-29 00:28:36
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 659 bytes
コンパイル時間 3,302 ms
コンパイル使用メモリ 278,316 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-04-29 00:28:42
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

/////////////////// メイン ///////////////////

int main () {
  
  //////////////////// 入力 ////////////////////

  int l, n;
  cin >> l >> n;

  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }

  //////////////// 出力変数定義 ////////////////

  int result = 0;

  //////////////////// 処理 ////////////////////

  sort(a.begin(),a.end());
  int sum = 0;
  for (int i : a) {
    sum += i;
    if (sum>l) break;
    result++;
  }

  //////////////////// 出力 ////////////////////

  cout << result << endl;

  //////////////////// 終了 ////////////////////

  return 0;

}
0