結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-02-09 22:15:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 373 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 43,776 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-21 22:02:21 |
合計ジャッジ時間 | 1,219 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d", &L); | ~~~~~^~~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d", &w); | ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { int L; int N; vector<int> v; scanf("%d", &L); scanf("%d", &N); while(N--) { int w; scanf("%d", &w); v.push_back(w); } sort(v.begin(), v.end()); int sum = 0; for(int i = 0; i < v.size(); i++) { sum += v[i]; if(sum > L) { printf("%d\n", i); break; } } }