結果

問題 No.871 かえるのうた
ユーザー ngtkanangtkana
提出日時 2020-03-10 20:32:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 168,516 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 23:35:44
合計ジャッジ時間 5,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 33
権限があれば一括ダウンロードができます

ソースコード

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