結果
問題 | No.871 かえるのうた |
ユーザー |
|
提出日時 | 2020-04-21 20:41:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 832 ms |
コンパイル使用メモリ | 73,064 KB |
最終ジャッジ日時 | 2025-01-09 22:08:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include <iostream>#include <vector>using lint = long long;void solve() {int n, k;std::cin >> n >> k;--k;std::vector<lint> xs(n), ys(n);for (auto& x : xs) std::cin >> x;for (auto& y : ys) std::cin >> y;int li = k, ri = k;lint l = xs[k] - ys[k], r = xs[k] + ys[k];bool update = true;while (update) {update = false;while (li - 1 >= 0 && xs[li - 1] >= l) {update = true;--li;l = std::min(l, xs[li] - ys[li]);r = std::max(r, xs[li] + ys[li]);}while (ri + 1 < n && xs[ri + 1] <= r) {update = true;++ri;l = std::min(l, xs[ri] - ys[ri]);r = std::max(r, xs[ri] + ys[ri]);}}std::cout << ri - li + 1 << std::endl;}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);solve();return 0;}