結果

問題 No.5 数字のブロック
ユーザー itezpace
提出日時 2016-07-12 07:43:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 357 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 65,120 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 14:11:55
合計ジャッジ時間 1,510 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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