結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cassert>
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;
  assert(1 <= K);
  vector<bool> cl(N);
  vector<int> x(K);
  for (int i = 0; i < K; i++)
  {
    cin >> x[i];
    x[i]--;
    cl[x[i]] = true;
  }
  int l = -1, r = K+1;
  while (abs(l - r) > 1)
  {
    int c = (l + r) / 2;
    int cnt = 0;
    int time = T;
    bool ok = true;
    for (int i = 0; i < N-1; i++)
    {
      time -= t[i];
      if (time <= 0)
      {
        ok = false;
        break;
      }
      if (cl[i+1] && cnt < c)
      {
        time += 10;
        cnt += 1;
      }
    }
    if (ok)
    {
      r = c;
    }
    else
    {
      l = c;
    }
  }
  if (r == K+1)
  {
    cout << -1 << '\n';
  }
  else
  {
    cout << r << '\n';
  }
  return 0;
}
/*
  File : ~/yukicoder/530/D.cpp
  Date : 2025/03/21
  Time : 21:33:10
*/
0