結果

問題 No.871 かえるのうた
ユーザー betrue12betrue12
提出日時 2019-08-30 21:46:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 165,048 KB
実行使用メモリ 4,980 KB
最終ジャッジ日時 2023-08-20 09:17:18
合計ジャッジ時間 4,858 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 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 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 108 ms
4,896 KB
testcase_15 AC 107 ms
4,864 KB
testcase_16 AC 116 ms
4,980 KB
testcase_17 AC 95 ms
4,784 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 AC 110 ms
4,868 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 42 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 9 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 34 ms
4,380 KB
testcase_30 AC 61 ms
4,476 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 50 ms
4,504 KB
testcase_33 AC 80 ms
4,900 KB
testcase_34 AC 19 ms
4,384 KB
testcase_35 AC 49 ms
4,380 KB
testcase_36 AC 69 ms
4,664 KB
testcase_37 AC 43 ms
4,376 KB
testcase_38 AC 94 ms
4,800 KB
testcase_39 AC 88 ms
4,704 KB
testcase_40 AC 28 ms
4,388 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 28 ms
4,396 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    K--;
    int64_t X[100000], A[100000];
    for(int i=0; i<N; i++) cin >> X[i];
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t L = X[K]-A[K], R = X[K]+A[K];
    int ans = 1;
    int l = K-1, r = K+1;
    while(true){
        bool updated = false;
        while(l >= 0 && L <= X[l]){
            ans++;
            updated = true;
            L = min(L, X[l]-A[l]);
            R = max(R, X[l]+A[l]);
            l--;
        }
        while(r < N && X[r] <= R){
            ans++;
            updated = true;
            L = min(L, X[r]-A[r]);
            R = max(R, X[r]+A[r]);
            r++;
        }
        if(!updated) break;
    }
    cout << ans << endl;
    return 0;
}
0