結果

問題 No.5 数字のブロック
ユーザー 0yuduki00yuduki0
提出日時 2016-08-21 21:01:47
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 64,468 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 22:28:40
合計ジャッジ時間 2,814 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(int argc, char** argv) {
  int l, n;
  cin >> l >> n;
  vector<int> w(n);
  cin >> w;
  sort(w.begin(), w.end());
  int ans = 0, sum = 0;
  while (sum < l) sum += w.at(ans++);
  cout << ans - 1 << endl;
}
0