結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-02-08 16:35:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 785 ms |
| コンパイル使用メモリ | 64,924 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 08:08:42 |
| 合計ジャッジ時間 | 1,692 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>
int
main(void)
{
std::cin.tie(0);
std::ios::sync_with_stdio(false);
int len, n;
std::cin >> len >> n;
std::vector<int> blockWidths;
for (int i = 0; i < n; i++) {
int w;
std::cin >> w;
blockWidths.emplace_back(w);
}
std::sort(blockWidths.begin(), blockWidths.end());
int sum = 0;
decltype(blockWidths)::size_type i = 0;
for (; i < blockWidths.size() && (sum += blockWidths[i]) <= len; i++);
std::cout << i << std::endl;
return EXIT_SUCCESS;
}