結果
問題 | No.871 かえるのうた |
ユーザー |
|
提出日時 | 2019-08-30 21:46:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 120 ms / 2,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 1,327 ms |
コンパイル使用メモリ | 166,328 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 10:45:43 |
合計ジャッジ時間 | 4,008 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int N, K;cin >> N >> K;K--;int64_t X[100000], A[100000];for(int i=0; i<N; i++) cin >> X[i];for(int i=0; i<N; i++) cin >> A[i];int64_t L = X[K]-A[K], R = X[K]+A[K];int ans = 1;int l = K-1, r = K+1;while(true){bool updated = false;while(l >= 0 && L <= X[l]){ans++;updated = true;L = min(L, X[l]-A[l]);R = max(R, X[l]+A[l]);l--;}while(r < N && X[r] <= R){ans++;updated = true;L = min(L, X[r]-A[r]);R = max(R, X[r]+A[r]);r++;}if(!updated) break;}cout << ans << endl;return 0;}