結果
問題 | No.871 かえるのうた |
ユーザー |
![]() |
提出日時 | 2019-08-30 23:00:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 1,612 ms |
コンパイル使用メモリ | 169,008 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 10:49:46 |
合計ジャッジ時間 | 3,279 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;signed main(){ios::sync_with_stdio(false);cin.tie(0);ll n,k;cin>>n>>k;k--;ll x[n],a[n];for(int i=0;i<n;i++){cin>>x[i];}for(int i=0;i<n;i++){cin>>a[i];}ll r=k,l=k,up=x[k]+a[k],low=x[k]-a[k];while(true){ll pr=r,pl=l;while(r<n && up>=x[r]){up = max(x[r]+a[r],up);low = min(low,x[r]-a[r]);r++;}while(l>=0 && low<=x[l]){up = max(up,x[l] + a[l]);low = min(low, x[l]-a[l]);l--;}if(pr==r && pl==l) break;}// cerr<<l<<" "<<r<<endl;// cerr<<low<<" "<<up<<endl;cout << r-l-1 << endl;}