結果

問題 No.871 かえるのうた
ユーザー lumc_lumc_
提出日時 2019-08-30 21:28:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 109,664 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-05-07 16:20:49
合計ジャッジ時間 3,481 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 56 ms
11,136 KB
testcase_15 AC 55 ms
11,136 KB
testcase_16 AC 64 ms
11,264 KB
testcase_17 AC 54 ms
10,880 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 58 ms
11,136 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 22 ms
6,272 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 28 ms
8,448 KB
testcase_30 AC 40 ms
9,088 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 37 ms
8,704 KB
testcase_33 AC 51 ms
11,392 KB
testcase_34 AC 13 ms
5,632 KB
testcase_35 AC 29 ms
8,192 KB
testcase_36 AC 40 ms
9,984 KB
testcase_37 AC 24 ms
6,528 KB
testcase_38 AC 54 ms
10,752 KB
testcase_39 AC 53 ms
10,496 KB
testcase_40 AC 29 ms
8,704 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 35 ms
8,832 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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;
}
0