結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2015-02-26 13:27:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 315 ms |
コンパイル使用メモリ | 43,776 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 22:30:54 |
合計ジャッジ時間 | 1,146 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf ("%d",&L); | ~~~~~~^~~~~~~~~ main.cpp:12:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf ("%d",&N); | ~~~~~~^~~~~~~~~ main.cpp:16:13: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf ("%d",&i); | ~~~~~~^~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main(void) { int L,N,c = 0; vector<int> W; scanf ("%d",&L); scanf ("%d",&N); for (int t = 0; t < N ; ++t) { int i; scanf ("%d",&i); W.push_back(i); } sort (W.begin(),W.end()); for (auto w : W) { L -= w; if (L >= 0) { c++; } else { break; } } printf("%d\n", c); return 0; }