結果
問題 | No.871 かえるのうた |
ユーザー |
![]() |
提出日時 | 2024-01-23 03:46:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 2,130 ms |
コンパイル使用メモリ | 194,184 KB |
最終ジャッジ日時 | 2025-02-18 22:12:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);ll n,k;cin>>n>>k;k--;vector<ll> X(n),A(n);rep(i,n) cin>>X[i];rep(i,n) cin>>A[i];int ln=k,rn=k;ll l=X[k]-A[k],r=X[k]+A[k];while(1){int c=0;if(ln-1>=0 && l<=X[ln-1]){c++;ln--;l=min(l,X[ln]-A[ln]);r=max(r,X[ln]+A[ln]);}if(rn+1<n && X[rn+1]<=r){c++;rn++;l=min(l,X[rn]-A[rn]);r=max(r,X[rn]+A[rn]);}if(c==0) break;}cout<<rn-ln+1<<endl;return 0;}