結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
MasWag
|
| 提出日時 | 2015-02-26 13:26:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 450 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 44,160 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 23:47:04 |
| 合計ジャッジ時間 | 1,589 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf ("%d",&L);
| ~~~~~~^~~~~~~~~
main.cpp:12:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf ("%d",&N);
| ~~~~~~^~~~~~~~~
main.cpp:16:13: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf ("%d",&i);
| ~~~~~~^~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
int L,N,c = 0;
vector<int> W;
scanf ("%d",&L);
scanf ("%d",&N);
for (int t = 0; t < N ; ++t)
{
int i;
scanf ("%d",&i);
W.push_back(i);
}
sort (W.begin(),W.end());
for (auto w : W)
{
L -= w;
if (L > 0)
{
c++;
}
else
{
break;
}
}
printf("%d\n", c);
return 0;
}
MasWag