結果

問題 No.871 かえるのうた
ユーザー otamay6otamay6
提出日時 2019-08-31 00:04:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 169,720 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 22:15:46
合計ジャッジ時間 4,997 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 119 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 128 ms
5,376 KB
testcase_17 AC 104 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 46 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 37 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 55 ms
5,376 KB
testcase_33 WA -
testcase_34 AC 21 ms
5,376 KB
testcase_35 AC 53 ms
5,376 KB
testcase_36 AC 75 ms
5,376 KB
testcase_37 WA -
testcase_38 AC 104 ms
5,376 KB
testcase_39 AC 97 ms
5,376 KB
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 31 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 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(){
    typedef long long ll;
    int N, K; cin >> N >> K;
    vector<ll> X(N), A(N);
    REP(i, N) cin >> X[i];
    REP(i, N) cin >> A[i];
    K--;
    ll l = X[K] - A[K];
    ll r = X[K] + A[K];
    int res = 0;
    int a = K, b = K;
    while (true) {
        int ld = lower_bound(All(X), l) - X.begin();
        int rd = upper_bound(All(X), r) - X.begin();
    
        for (int i = ld; i < a; ++i) {
            l = min(l, X[i] - A[i]);
            r = max(r, X[i] + A[i]);
        }
        for (int i = b+1; i < rd; ++i) {
            l = min(l, X[i] - A[i]);
            r = max(r, X[i] + A[i]);
        }
        int tmp=res;
        res = rd - ld ;
        if(res==tmp) break;
        a = ld, b = rd;
    }
    cout << res << endl;
    return 0;
}
0