結果

問題 No.871 かえるのうた
ユーザー ngtkanangtkana
提出日時 2020-03-10 20:32:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 170,388 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 18:50:30
合計ジャッジ時間 4,155 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
void cmn(lint&x,lint y){if(x>y)x=y;}
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n,k;std::cin>>n>>k;k--;
    std::vector<lint>a(n),b(n);
    for(auto&x:a)std::cin>>x;
    for(auto&x:b)std::cin>>x;
    lint L=a.at(k)-b.at(k);
    lint R=a.at(k)+b.at(k);
    int l=k,r=k;
    while(true){
        if(0<l&&L<=a.at(l-1)){
            l--;
            cmn(L,a.at(l)-b.at(l));
            cmn(R,a.at(l)+b.at(l));
            continue;
        }
        if(r<n-1&&a.at(r+1)<=R){
            r++;
            cmn(L,a.at(r)-b.at(r));
            cmn(R,a.at(r)+b.at(r));
            continue;
        }
        break;
    }
    std::cout<<r-l+1<<'\n';
}
0