結果

問題 No.3067 +10 Seconds Clock
ユーザー tobbie
提出日時 2025-04-07 18:32:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 193,860 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-04-07 18:33:00
合計ジャッジ時間 3,874 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> ti(n, 0), xi(n, 0);
  rep(i, n-1) cin >> ti[i];
  int k;
  cin >> k;
  rep(i, k) {
    int x; cin >> x;
    xi[x-1] = 10;
  }
  t -= ti[0];
  int cnt = 0;
  int res = 0;
  rep(i, n-1) {
    res += xi[i];
    if (t - ti[i+1] <= 0) {
      while (res > 0 && t <= ti[i+1]) {
	t += 10;
	cnt++;
	res -= 10;
      }
    }
    t -= ti[i+1];
    if (t < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;
  return 0;
}
0