結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-03 19:38:46 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 326 bytes |
| 記録 | |
| コンパイル時間 | 634 ms |
| コンパイル使用メモリ | 77,048 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-04 11:05:44 |
| 合計ジャッジ時間 | 2,374 ms |
|
ジャッジサーバーID (参考情報) |
judge5_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function 'int main(int, const char**)':
main.cpp:20:20: warning: 'cnt' may be used uninitialized [-Wmaybe-uninitialized]
20 | cnt++;
| ~~~^~
main.cpp:13:13: note: 'cnt' was declared here
13 | int cnt;
| ^~~
ソースコード
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, const char* argv[])
{
int L, N;
cin >> L >> N;
int W[N];
for (auto&& w : W) cin >> w;
sort(W, &W[N]);
int cnt;
int sum = 0;
for (auto&& w : W) {
sum += w;
if (sum > L) {
break;
}
cnt++;
}
cout << cnt << endl;
return 0;
}