結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2017-08-26 00:09:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 358 bytes |
コンパイル時間 | 975 ms |
コンパイル使用メモリ | 43,996 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 11:38:49 |
合計ジャッジ時間 | 1,964 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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", &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); | ~~~~~^~~~~~~~~~ main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &t); | ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int main() { int L, N, t; scanf("%d", &L); scanf("%d", &N); vector<int> W; for(int i = 0; i < N; i++) { scanf("%d", &t); W.push_back(t); } sort(W.begin(), W.end()); int S = 0, i = 0; for(; i < N; i++) { S += W[i]; if(S > L) { break; } } printf("%d", i); }