結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-09-11 20:17:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 500 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 44,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 17:04:31 |
合計ジャッジ時間 | 1,364 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", &L); | ~~~~~^~~~~~~~~~ main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d", &t); | ~~~~~^~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <vector> #include <algorithm> //sort #include <cstdlib> using namespace std; int main() { int L, N; vector<int> vc; int t; int ans = 0; scanf("%d", &L); scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &t); vc.push_back(t); } sort(vc.begin(), vc.end()); for (int i = 0; i < N; i++) { L -= vc.front(); if (L <= 0) break; vc.erase(vc.begin()); ans++; } printf("%d", ans); //system("PAUSE"); return 0; }