結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2017-06-19 20:14:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 394 bytes |
コンパイル時間 | 1,641 ms |
コンパイル使用メモリ | 162,140 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 11:15:31 |
合計ジャッジ時間 | 2,274 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d\n", &L); | ~~~~~^~~~~~~~~~~~ main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d\n", &N); | ~~~~~^~~~~~~~~~~~ main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &temp); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> int main() { int L, N; std::vector<int> W; scanf("%d\n", &L); scanf("%d\n", &N); for (int i = 0; i < N; i++) { int temp; scanf("%d", &temp); W.push_back(temp); } std::sort(W.begin(), W.end()); int count, total = 0; for (count = 0; count < W.size(); count++) { total += W.at(count); if (total > L) break; } printf("%d\n", count); return 0; }