結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
ichiruisyu
|
| 提出日時 | 2016-07-04 12:16:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 361 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 34,432 KB |
| 最終ジャッジ日時 | 2024-11-14 19:45:58 |
| 合計ジャッジ時間 | 604 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:34: error: ‘less’ was not declared in this scope
17 | sort(W.begin(), W.end(), less<int>());
| ^~~~
main.cpp:17:39: error: expected primary-expression before ‘int’
17 | sort(W.begin(), W.end(), less<int>());
| ^~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d%d", &L, &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", &W[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int L, N;
scanf("%d%d", &L, &N);
vector<int> W(N);
for (int i = 0; i < N; i++) {
scanf("%d", &W[i]);
}
sort(W.begin(), W.end(), less<int>());
int ans = 0;
for (; ans < N; ans++) {
L -= W[ans];
if (L < 0) break;
}
printf("%d\n", ans);
return 0;
}
ichiruisyu