結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-03 19:38:46 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 5,000 ms |
| + 235µs | |
| コード長 | 326 bytes |
| 記録 | |
| コンパイル時間 | 355 ms |
| コンパイル使用メモリ | 76,664 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-26 22:34:23 |
| 合計ジャッジ時間 | 1,983 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}