結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-09-11 20:27:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 470 bytes |
コンパイル時間 | 404 ms |
コンパイル使用メモリ | 43,904 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 11:41:26 |
合計ジャッジ時間 | 1,432 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
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[i]; if (L < 0) break; ans++; } printf("%d", ans); //system("PAUSE"); return 0; }