結果

問題 No.3067 +10 Seconds Clock
ユーザー elphe
提出日時 2025-03-31 12:54:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 901 ms
コンパイル使用メモリ 85,016 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-31 12:54:24
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

static inline constexpr int32_t solve(const uint32_t N, uint32_t T, const uint32_t K, const vector<uint32_t>& t, const vector<uint32_t>& x)
{
	uint32_t stock = 0, used = 0;
	for (uint32_t i = 2, j = 0; i != N + 1; ++i)
	{
		if (t[i] >= T)
		{
			const uint32_t need = (t[i] - T) / 10 + 1;
			if (need > stock) return -1;
			stock -= need, used += need, T = T + need * 10 - t[i];
		}
		else
			T -= t[i];

		if (i == x[j])
			++stock, ++j;
	}

	return used;
}

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	
	uint32_t N, T, K, i;
	cin >> N >> T;
	vector<uint32_t> t(N + 1);
	for (i = 2; i != N + 1; ++i) cin >> t[i];

	cin >> K;
	vector<uint32_t> x(K + 1);
	for (i = 0; i != K; ++i) cin >> x[i];
	x[K] = UINT32_MAX;

	cout << solve(N, T, K, t, x) << '\n';
	return 0;
}
0