結果

問題 No.871 かえるのうた
ユーザー iqueue02iqueue02
提出日時 2019-10-23 22:19:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 173,140 KB
実行使用メモリ 4,692 KB
最終ジャッジ日時 2023-09-21 11:15:40
合計ジャッジ時間 8,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 112 ms
4,568 KB
testcase_15 WA -
testcase_16 AC 154 ms
4,504 KB
testcase_17 AC 99 ms
4,560 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 10 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 35 ms
4,380 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n, k;
  cin >> n >> k;
  k--;
  vector<ll> x(n), a(n);
  rep(i,n) cin >> x[i];
  rep(i,n) cin >> a[i];
  
  queue<int> que;
  que.push(k);
  int minl = n+1, maxr = 0;

  vector<bool> ok(n,false);

  while (!que.empty()){
    int i = que.front(); que.pop();
    ok[i] = true;
    int l = lower_bound(x.begin(), x.end(), x[i] - a[i]) - x.begin();
    int r = upper_bound(x.begin(), x.end(), x[i] + a[i]) - x.begin();
    r--;
    if (!ok[l]) que.push(l);
    if (!ok[r]) que.push(r); 
    if (minl > l) minl = l;
    if (maxr < r) maxr = r;
    //cout << l << " " << r << endl;
  }
  cout << maxr - minl + 1 << endl;
  return 0;
}
0