結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
ichiruisyu
|
| 提出日時 | 2016-07-04 12:16:13 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 361 bytes |
| 記録 | |
| コンパイル時間 | 977 ms |
| コンパイル使用メモリ | 170,688 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 16:06:41 |
| 合計ジャッジ時間 | 1,785 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 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%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