結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
pinebooks
|
| 提出日時 | 2017-08-26 16:43:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 477 bytes |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 43,648 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 17:46:01 |
| 合計ジャッジ時間 | 1,361 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d%d", &L, &N);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
/*
* 5.cpp
*
* Created on: 2017/08/26
* Author: pinebooks
*/
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int L, N;
scanf("%d%d", &L, &N);
vector<int> W;
for (int i = 0; i < N; ++i) {
int a;
scanf("%d", &a);
W.push_back(a);
}
sort(W.begin(), W.end());
int sum = 0;
int i = 0;
while (true) {
if (sum + W[i + 1] > L)
break;
++i;
sum += W[i];
}
printf("%d", i + 1);
}
pinebooks