結果

問題 No.5 数字のブロック
ユーザー k_kiri
提出日時 2019-03-21 10:11:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 408 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 170,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 01:26:04
合計ジャッジ時間 2,296 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

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