結果

問題 No.5 数字のブロック
コンテスト
ユーザー ui_mtc
提出日時 2020-08-20 01:37:49
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 5,000 ms
+ 453µs
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 993 ms
コンパイル使用メモリ 186,224 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-14 18:32:12
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed 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());

  int now = 0;
  for( int i = 0; i < N; i++ ){
    if( now+W[i] > L ){
      cout << i << endl;
      return 0;
    }
    now += W[i];
  }
  cout << N << endl;
}
0