結果

問題 No.3067 +10 Seconds Clock
ユーザー forest3
提出日時 2025-03-22 11:02:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 163,584 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-22 11:02:32
合計ジャッジ時間 4,095 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int N, T, K;
	cin >> N >> T;
	vector<int> t(N - 1);
	rep(i, N - 1) cin >> t[i];
	cin >> K;
	vector<int> x(N);
	rep(i, K) {
		int a;
		cin >> a;
		x[a - 1] = 1;
	}
	int now = T, ans = 0, cnt = 0;
	rep(i, N - 1) {
		if(now && x[i]) {
			cnt++;
		}
		if(now - t[i] <= 0) {
			while(cnt && now - t[i] <= 0) {
				now += 10;
				ans++;
				cnt--;
			}
			now -= t[i];
			if(now <= 0) {
				cout << -1 << endl;
				return 0;
			}
		}
		else now -= t[i];
	}
	cout << ans << endl;
} 
0