結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-11-11 23:44:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 607 bytes |
コンパイル時間 | 612 ms |
コンパイル使用メモリ | 65,320 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 10:33:22 |
合計ジャッジ時間 | 1,700 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(int argc, char const *argv[]) { int boxSize; int blockNum; vector<int> blockWidth; cin >> boxSize >> blockNum; int i, tmp; for(i = 0; i < blockNum; i++){ cin >> tmp; blockWidth.push_back(tmp); } sort(blockWidth.begin(), blockWidth.end()); int count = 0; int sum = 0; while((count < blockNum) && ((sum + blockWidth.at(count)) <= boxSize)){ sum = sum + blockWidth.at(count); count++; } cout << count << endl; return 0; }