結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-12 01:28:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 983 bytes |
| コンパイル時間 | 751 ms |
| コンパイル使用メモリ | 70,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 10:43:25 |
| 合計ジャッジ時間 | 3,821 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
typedef long long ll;
ll ma = 100000000000000000;
int main(){
int n, k;
cin >> n >> k;
assert(1 <= n && n <= 100000);
assert(1 <= k && k <= n);
k--;
vector<ll> x(n), a(n);
for(int i = 0; i < n; i++) cin >> x[i], assert(-ma < x[i] && x[i] < ma && (i == 0 || x[i-1] < x[i]));
for(int i = 0; i < n; i++) cin >> a[i], assert(-ma < a[i] && a[i] < ma);
ll ld = x[k]-a[k], rd = x[k]+a[k];
int l = k, r = k;
bool update = true;
while(update){
update = false;
while(l-1 >= 0 && ld <= x[l-1]){
update = true;
l--;
ld = min(ld, x[l]-a[l]);
rd = max(rd, x[l]+a[l]);
}
while(r+1 < n && x[r+1] <= rd){
update = true;
r++;
rd = max(rd, x[r]+a[r]);
ld = min(ld, x[r]-a[r]);
}
}
cout << r-l+1 << endl;
return 0;
}