結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
mine691
|
| 提出日時 | 2019-08-15 00:02:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 1,575 ms |
| コンパイル使用メモリ | 170,836 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 14:40:34 |
| 合計ジャッジ時間 | 2,574 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
int N, L;
int main()
{
cin >> L >> N;
vector<int> w(N);
for (int i = 0; i < N; i++)
{
cin >> w[i];
}
int s = 0, ans = 0;
sort(w.begin(), w.end());
for (int i = 0; i < N; i++)
{
if (s + w[i] <= L)
s += w[i], ans++;
}
cout << ans << endl;
}
mine691