結果

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

ソースコード

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;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

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;
    t--;
    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]) cnt++;
    }
    cout << ans << '\n';
}
0