結果

問題 No.871 かえるのうた
ユーザー k
提出日時 2020-07-07 20:01:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 2,821 ms
コンパイル使用メモリ 195,788 KB
最終ジャッジ日時 2025-01-11 16:43:08
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  vector<long long> x(n), a(n);
  REP (i, n) cin >> x[i];
  REP (i, n) cin >> a[i];

  --k;

  pair<int, int> p = {k, k};
  bool update = true;

  while (update) {
    update = false;

    int lb, ub;
    tie(lb, ub) = p;
    while (lb-1 >= 0 && x[p.first] - a[p.first] <= x[lb-1])
      --lb;
    while (ub+1 <n && x[ub+1] <= x[p.second] + a[p.second])
      ++ub;

    if (lb < p.first || p.second < ub) update = true;
    p = {lb, ub};
  }

  cout << (p.second - p.first + 1) << endl;
  
  return 0;
}
0