結果
問題 |
No.871 かえるのうた
|
ユーザー |
|
提出日時 | 2019-10-26 01:00:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 1,085 bytes |
コンパイル時間 | 572 ms |
コンパイル使用メモリ | 85,500 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 10:57:35 |
合計ジャッジ時間 | 3,736 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <iostream> #include <iomanip> #include <cstring> #include <algorithm> #include <math.h> #include <queue> #include <functional> #include <map> #include <vector> #include <string> #include <set> using namespace std; typedef long long ll; typedef pair<ll, int> P; typedef pair<pair<int, int>, int> PP; const ll INF = 1e15; const int MAX = 510000; const ll MOD = 1000000007; int main(void) { int N, K; cin >> N >> K; K--; vector<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]; int l, r; ll lX, rX; bool update = true; l = r = K; lX = X[K] - A[K]; rX = X[K] + A[K]; while (update) { update = false; while (r < N && X[r] <= rX) { if (rX < X[r] + A[r]) { rX = X[r] + A[r]; update = true; } if (X[r] - A[r] < lX) { lX = X[r] - A[r]; update = true; } r++; } while (0 <= l && lX <= X[l]) { if (X[l] - A[l] < lX) { lX = X[l] - A[l]; update = true; } if (rX < X[l] + A[l]) { rX = X[l] + A[l]; update = true; } l--; } } cout << r - l - 1 << endl; }