結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-02-09 22:23:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 448 bytes |
| コンパイル時間 | 452 ms |
| コンパイル使用メモリ | 43,904 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-21 22:02:26 |
| 合計ジャッジ時間 | 1,396 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
コンパイルメッセージ
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;
bool flag = true;
for(int i = 0; i < v.size(); i++) {
sum += v[i];
if(sum >= L) {
printf("%d\n", i);
flag = false;
break;
}
}
if(flag) printf("%lu\n", v.size());
}