結果

問題 No.871 かえるのうた
ユーザー ngtkanangtkana
提出日時 2020-03-09 22:08:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 170,588 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-14 13:44:07
合計ジャッジ時間 4,698 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
template<class T>void cmn(T&x,T y){if(x>y)x=y;}
template<class T>void cmx(T&x,T 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<long long>a(n),b(n);
    for(auto&&x:a)std::cin>>x;
    for(auto&&x:b)std::cin>>x;
    long long L=a.at(k)-b.at(k),R=a.at(k)+b.at(k);
    int l=k,r=k;
    for(;l>=0;l--){
        if(l==0||a.at(l-1)<L)break;
        cmn(L,a.at(l-1)-b.at(l-1));
    }
    for(;r<n;r++){
        if(r==n-1||R<a.at(r+1))break;
        cmx(R,a.at(r+1)+b.at(r+1));
    }
    std::cout<<r-l+1<<'\n';
}
0