結果

問題 No.871 かえるのうた
ユーザー kk
提出日時 2020-07-07 20:01:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 198,300 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 18:31:05
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 41 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 43 ms
6,940 KB
testcase_17 AC 36 ms
6,944 KB
testcase_18 AC 8 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 5 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 15 ms
6,944 KB
testcase_30 WA -
testcase_31 AC 2 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 9 ms
6,944 KB
testcase_35 WA -
testcase_36 AC 26 ms
6,944 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 12 ms
6,940 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 12 ms
6,940 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,944 KB
testcase_48 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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