結果
問題 |
No.871 かえるのうた
|
ユーザー |
![]() |
提出日時 | 2019-12-28 03:36:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 895 bytes |
コンパイル時間 | 1,723 ms |
コンパイル使用メモリ | 168,404 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 10:59:10 |
合計ジャッジ時間 | 3,815 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<ll> x(n); vector<ll> a(n); rep(i, n) cin >> x[i]; rep(i, n) cin >> a[i]; k--; ll r = x[k] + a[k];//right ll l = x[k] - a[k];//left bool elf = true; int b = k; int c = k; while (elf) { elf = false; if (b - 1 >= 0) { ll i = b - 1; if (l <= x[i] && x[i] <= r) { b = i; l = min(l, x[i] - a[i]); r = max(r, x[i] + a[i]); elf = true; continue; } } if (c + 1 <= n - 1) { ll i = c + 1; if (l <= x[i] && x[i] <= r) { c = i; l = min(l, x[i] - a[i]); r = max(r, x[i] + a[i]); elf = true; continue; } } } ll ans = c - b + 1; dunk(ans); return 0; }