結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2015-01-13 19:58:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 401 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 63,284 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 04:39:13 |
合計ジャッジ時間 | 4,566 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &width); | ~~~~~^~~~~~~~~~~~~~ main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &block[i]); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<iostream> #include<vector> #include <algorithm> using namespace std; int main(void) { vector<int> block; int width, N, riz; scanf("%d", &width); scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%d", &block[i]); sort(block.begin(), block.end()); for(riz = 0; (riz < N) && (width > 0); riz++) width -= block[riz]; if(width < 0) riz--; printf("%d\n", riz); return 0; }