結果

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
#include<sstream>
using namespace std;


int main(){
  int l,n;
  int ans=0;
  cin >> l;
  cin >> n;
  vector<int> w;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    w.push_back(tmp);
  }

  sort(w.begin(),w.end());
  for(int i=0;i<w.size();i++){
    l -= w[i];
    if(l <= 0) break;
    ans++;
  }

  cout << ans << endl;

  return 0;
}
0