結果

問題 No.871 かえるのうた
ユーザー mmn15277198mmn15277198
提出日時 2021-10-09 11:57:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 864 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 98,932 KB
実行使用メモリ 6,780 KB
最終ジャッジ日時 2023-10-09 21:07:36
合計ジャッジ時間 5,871 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,384 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 100 ms
6,228 KB
testcase_18 AC 17 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 9 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 36 ms
5,396 KB
testcase_30 WA -
testcase_31 AC 3 ms
4,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 20 ms
4,380 KB
testcase_35 WA -
testcase_36 AC 73 ms
6,048 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 30 ms
5,392 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 30 ms
5,468 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,384 KB
testcase_48 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>

using namespace std;

int main() {
  int n , k;
  cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  vector<pair<long long , long long> > p(n);

  for (int i = 0; i < n; i++) {
    p[i]= make_pair(a[i] - x[i] , a[i] + x[i]);
  }

  k--;
  vector<int> cnt(n , 0);
  cnt[k] = 1;
  for (int i = k; i < n - 1; i++) {
    if (p[i].second >= a[i + 1]) cnt[i + 1] = cnt[i];
  }
  for (int i = k; i >= 1; i--) {
    if (p[i].first <= a[i - 1]) cnt[i - 1] = cnt[i];
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += cnt[i] > 0;
  }
  cout << ans << endl;
  return 0;
}
0