結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
iwashi31
|
| 提出日時 | 2014-11-19 23:26:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 628 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 73,628 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 22:02:47 |
| 合計ジャッジ時間 | 1,674 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
int L, N;
multiset<int> box;
int main() {
int i;
int count = 0;
cin >> L;
cin >> N;
for (i = 0; i < N; i++) {
int input;
cin >> input;
box.insert(input);
}
while (!box.empty() && L > 0) {
multiset<int>::iterator it = box.begin();
if (L >= (*it)) {
L -= (*it);
box.erase(it);
count++;
} else break;
}
cout << count << endl;
return 0;
}
iwashi31