結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-18 09:39:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 428 bytes |
| コンパイル時間 | 563 ms |
| コンパイル使用メモリ | 66,496 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-18 08:16:52 |
| 合計ジャッジ時間 | 1,565 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
int main(){
int L,N;
std::vector<int> W{};
std::cin >> L >> N;
W.reserve(N);
std::copy_n(std::istream_iterator<int>(std::cin),N,std::back_inserter(W));
std::sort(W.begin(),W.end());
auto how_many = 0;
for(auto w : W){
if(L >= w){
L -= w;
++how_many;
}
}
std::cout << how_many << std::endl;
return 0;
}