結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
lumc_
|
| 提出日時 | 2019-08-30 21:28:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 1,012 bytes |
| コンパイル時間 | 888 ms |
| コンパイル使用メモリ | 108,508 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-11-30 10:44:49 |
| 合計ジャッジ時間 | 3,199 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;
constexpr int N = 1e5;
ll a[N], x[N];
int main() {
std::ios::sync_with_stdio(false), std::cin.tie(0);
int n, k;
cin >> n >> k;
k--;
using P = pair<ll, ll>;
set<pair<ll, ll>> v;
for(int i = 0; i < n; i++) cin >> x[i];
for(int i = 0; i < n; i++) cin >> a[i], v.emplace(x[i], a[i]);
ll l = x[k], r = l;
int ans = 0;
while(1) {
auto ite = v.lower_bound(P(l, 0));
if(ite != v.end() and ite->first <= r) {
auto p = *ite;
v.erase(ite);
l = min(l, p.first - p.second);
r = max(r, p.first + p.second);
ans++;
} else break;
}
cout << ans << endl;
return 0;
}
lumc_