結果
問題 | No.871 かえるのうた |
ユーザー |
![]() |
提出日時 | 2019-08-30 23:13:08 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 130 ms / 2,000 ms |
コード長 | 1,001 bytes |
コンパイル時間 | 1,040 ms |
コンパイル使用メモリ | 99,592 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 10:50:20 |
合計ジャッジ時間 | 4,229 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#include <utility>#include <functional>#define popcount __builtin_popcountusing namespace std;typedef long long int ll;typedef pair<ll, int> P;int main(){int n, k; cin>>n>>k;k--;ll x[100010], a[100010];for(int i=0; i<n; i++) cin>>x[i];for(int i=0; i<n; i++) cin>>a[i];int l=k, r=k;int cnt=1;ll mn=x[k]-a[k], mx=x[k]+a[k];for(int i=0; i<n+10; i++){ll mn1=mn, mx1=mx;while(l-1>=0 && mn<=x[l-1]){l--;cnt++;mn1=min(mn1, x[l]-a[l]);mx1=max(mx1, x[l]+a[l]);}while(r+1<n && mx>=x[r+1]){r++;cnt++;mn1=min(mn1, x[r]-a[r]);mx1=max(mx1, x[r]+a[r]);}mn=mn1, mx=mx1;}cout<<cnt<<endl;return 0;}