結果

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

ソースコード

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];
    cl[x[i]-1] = 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] && 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