結果

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

ソースコード

diff #

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> t(n - 1);
    for (int i = 0; i < n - 1; i++)
    {
        cin >> t[i];
    }
    int k;
    cin >> k;
    vector<int> x(k);
    for (int i = 0; i < k; i++)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    priority_queue<int> q;
    int x_index = 0;
    int cnt = 0;
    long long cur = m;
    int cur_pos = 1;
    for (int i = 0; i < n - 1; ++i)
    {
        while (x_index < k && x[x_index] <= cur_pos)
        {
            q.push(x[x_index]);
            x_index++;
        }
        long long y = cur - t[i];
        while (y <= 0 && !q.empty())
        {
            cur += 10;
            cnt++;
            q.pop();
            y = cur - t[i];
        }
        if (y <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        cur = y;
        cur_pos++;
    }
    if (cur <= 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << cnt << endl;
    }
    return 0;
}
0