結果

問題 No.5 数字のブロック
ユーザー elpheelphe
提出日時 2024-08-19 12:26:24
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 83,924 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-19 12:26:27
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC  target("sse4,avx,tune=native")
#pragma GCC  optimize("O3")

#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint16_t L, N, i, sum = 0;
	cin >> L >> N;
	vector<uint16_t> W(N);
	for (i = 0; i != N; ++i) cin >> W[i];

	sort(W.begin(), W.end());
	for (i = 0; i != N; ++i)
	{
		sum += W[i];
		if (sum > L) break;
	}

	cout << i << '\n';
	return 0;
}
0