結果

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

ソースコード

diff #

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

int main() {
  int N, T, K;
  cin >> N >> T;
  assert(2 < N && N <= (int)2e5 && 0 < T && T <= (int)4e6);
  vector<int> t(N - 1, 0), sum(N, 0);
  for(int i = 1; i < N; i++) {
    cin >> t.at(i - 1);
    sum.at(i) = sum.at(i - 1) + t.at(i - 1);
    assert(0 < t.at(i - 1) && t.at(i - 1) < 21);
  }
  cin >> K;
  assert(0 < K && K < N - 1);
  int x_max = 0;
  vector<int> x(K, 0);
  for(int &o : x) {
    cin >> o;
    assert(x_max < o && 1 < o && o < N);
    x_max = o, o--;
  }
  bool f = false;
  int tmp = T;
  for(int i = 0; i < K; i++) {
    if(tmp + 10 * i <= sum.at(x.at(i))) {
      f = true;
    }
  }
  if(f) {
    cout << -1 << endl;
    return 0;
  }
  int l = -1, r = K, c = 0;
  while(r - l > 1) {
    c = (l + r) / 2;
    if(tmp + 10 * c <= sum.at(N - 1)) {
      l = c;
    }
    else {
      r = c;
    }
  }
  cout << r << endl;
}
0