結果

問題 No.5 数字のブロック
ユーザー __gusari__gusari
提出日時 2017-05-09 23:30:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 344 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-18 11:03:36
合計ジャッジ時間 1,621 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main(){
  int l, n, i;
  cin >> l >> n;
  vector<int> w(n);
  for(i = 0; i < n; ++i){
    cin >> w[i];
  }
  sort(w.begin(), w.end());
  int cnt = 0;
  while(cnt != n){
    l -= w[cnt];
    if(l < 0)break;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}
0