結果

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

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n - 1);
    cin >> a;
    ll k;
    cin >> k;
    vector<bool> used(n);
    for(int i = 0; i < k; i++){
        int v;
        cin >> v;
        v--;
        used[v] = true;
    }

    int cnt = 0, ans = 0;
    for(int i = 0; i + 1 < n; i++){
        while(cnt >= 1 && t <= a[i]){
            t += 10;
            ans++;
            cnt--;
        }
        t -= a[i];
        if(t <= 0){
            cout << "-1\n";
            return 0;
        }
        if(used[i + 1]) cnt++;
    }
    cout << ans << '\n';
}
0