結果

問題 No.871 かえるのうた
ユーザー otamay6otamay6
提出日時 2019-08-30 21:58:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 1,831 ms
コンパイル使用メモリ 166,332 KB
実行使用メモリ 6,392 KB
最終ジャッジ日時 2023-08-20 09:18:21
合計ジャッジ時間 5,006 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 15 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 114 ms
6,392 KB
testcase_15 AC 114 ms
6,148 KB
testcase_16 AC 123 ms
6,376 KB
testcase_17 AC 101 ms
5,836 KB
testcase_18 AC 18 ms
4,376 KB
testcase_19 AC 115 ms
6,248 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 44 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 6 ms
4,380 KB
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 36 ms
5,140 KB
testcase_30 AC 65 ms
5,428 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 53 ms
5,320 KB
testcase_33 AC 85 ms
6,148 KB
testcase_34 AC 20 ms
4,380 KB
testcase_35 AC 52 ms
5,008 KB
testcase_36 AC 72 ms
5,620 KB
testcase_37 AC 45 ms
4,384 KB
testcase_38 AC 100 ms
5,984 KB
testcase_39 AC 94 ms
5,616 KB
testcase_40 AC 31 ms
5,100 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 31 ms
5,096 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;

int main(){
    int N,K;cin>>N>>K;
    K--;
    vector<long long> X(N),A(N);
    REP(i,N) cin>>X[i];
    REP(i,N) cin>>A[i];
    vector<long long> ranl(N),ranr(N);
    REP(i,N) {
        ranl[i]=X[i]-A[i],ranr[i]=X[i]+A[i];
    }
    int l=K-1,r=K+1;
    long long left=ranl[K];
    long long right=ranr[K];
    while(0<=l||r<N){
        bool nuke=true;
        if(0<=l&&left<=X[l]){
            nuke=false;
            left=min(left,ranl[l]);
            right=max(right,ranr[l]);
            l--;
        }
        if(r<N&&X[r]<=right){
            nuke=false;
            right=max(ranr[r],right);
            left=min(left,ranl[r]);
            r++;
        }
        if(nuke) break;
    }
    cout<<r-l-1<<endl;
}
0