結果

問題 No.871 かえるのうた
ユーザー mmn15277198mmn15277198
提出日時 2021-10-09 15:09:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 885 bytes
コンパイル時間 1,180 ms
コンパイル使用メモリ 99,824 KB
実行使用メモリ 4,900 KB
最終ジャッジ日時 2023-10-10 00:32:12
合計ジャッジ時間 10,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 99 ms
4,544 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,372 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 35 ms
4,372 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 21 ms
4,376 KB
testcase_35 RE -
testcase_36 AC 71 ms
4,376 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 2 ms
4,372 KB
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 1 ms
4,372 KB
testcase_47 AC 2 ms
4,372 KB
testcase_48 AC 1 ms
4,372 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;
  k--;
  vector<long long> X(n);
  for (int i = 0; i < n; i++) {
    cin >> X[i];
  }
  vector<long long> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  int x = k , y = k;
  int ans = 0;
  long long mx = -1e18;
  long long mn = 1e18;
  queue<int> qx , qy;
  qx.push(k);
  qy.push(k);
  while (qx.size() > 0 || qy.size() > 0) {
    x = qx.front();
    qx.pop();
    mx = max(mx , X[x] + A[x]);
    if (x + 1 < n && X[x + 1] <= mx) {
      qx.push(x + 1);
    }
    y = qy.front();
    qy.pop();
    mn = min(mn , X[y] - A[y]);
    if (0 <= y - 1 && mn <= X[y - 1]) {
      qy.push(y - 1);
    }
  }
  cout << x - y + 1 << endl;
  return 0;
}
0