結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, T;
    cin >> n >> T;
    vector<int> t(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> t[i];
    }
    vector<bool> flg(n);
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        flg[x - 1] = true;
    }
    int ans = 0;
    int cur = 0;
    for (int i = 0; i < n - 1; i++) {
        if (flg[i]) {
            cur++;
        }
        while (T <= t[i]) {
            if (cur == 0) {
                cout << -1 << endl;
                return 0;
            }
            cur--;
            ans++;
            T += 10;
        }
        T -= t[i];
     }
    cout << ans << endl;
}
0