結果

問題 No.871 かえるのうた
ユーザー CleyLCleyL
提出日時 2022-08-18 21:56:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 4,756 KB
最終ジャッジ日時 2023-08-20 09:45:57
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 5 ms
4,388 KB
testcase_14 AC 112 ms
4,560 KB
testcase_15 AC 112 ms
4,564 KB
testcase_16 AC 123 ms
4,756 KB
testcase_17 AC 99 ms
4,576 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 AC 114 ms
4,648 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 43 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 10 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 34 ms
4,380 KB
testcase_30 AC 64 ms
4,380 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 52 ms
4,380 KB
testcase_33 AC 83 ms
4,684 KB
testcase_34 AC 20 ms
4,376 KB
testcase_35 AC 51 ms
4,380 KB
testcase_36 AC 71 ms
4,380 KB
testcase_37 AC 45 ms
4,376 KB
testcase_38 AC 99 ms
4,744 KB
testcase_39 AC 92 ms
4,484 KB
testcase_40 AC 29 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 30 ms
4,452 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,384 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;
int main(){
  long long n,k;cin>>n>>k;
  
  vector<long long> X(n),A(n);
  for(int i = 0; n > i; i++)cin>>X[i];
  for(int i = 0; n > i; i++)cin>>A[i];
  vector<bool> G(n);
  queue<int> b;
  b.push(k-1);
  int nwl = k-1,nwr = k-1;
  while(b.size()){
    auto z = b.front();b.pop();
    while(nwr+1 != n && X[nwr+1]-X[z] <= A[z]){
        nwr++;
        b.push(nwr);
    }
    while(nwl-1 >= 0 && X[z]-X[nwl-1] <= A[z]){
        nwl--;
        b.push(nwl);
    }
  }
  cout << nwr-nwl+1 << endl;
}
0