結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<int> t(N - 1);
  for (int i = 0; i < N - 1; i++){
    cin >> t[i];
  }
  int K;
  cin >> K;
  vector<bool> a(N, false);
  for (int i = 0; i < K; i++){
    int x;
    cin >> x;
    x--;
    a[x] = true;
  }
  int cnt = 0;
  int cnt2 = 0;
  for (int i = 0; i < N - 1; i++){
    while (T <= t[i] && cnt2 > 0){
      cnt2--;
      cnt++;
      T += 10;
    }
    if (T <= t[i]){
      cout << -1 << endl;
      return 0;
    }
    T -= t[i];
    if (a[i + 1]){
      cnt2++;
    }
  }
  cout << cnt << endl;
}
0