結果

問題 No.871 かえるのうた
ユーザー rodearodea
提出日時 2020-10-08 15:11:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,560 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 107,884 KB
実行使用メモリ 4,680 KB
最終ジャッジ日時 2023-09-27 11:49:56
合計ジャッジ時間 6,199 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 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 AC 36 ms
4,584 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 32 ms
4,532 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 4 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 13 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 8 ms
4,380 KB
testcase_35 WA -
testcase_36 AC 23 ms
4,380 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 12 ms
4,380 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k; cin>>n>>k;
    vector<ll> x(n+2), a(n+1);
    x[0] = -INF, x[n+1] = INF;
    for(int i=1; i<=n; i++) cin>>x[i];
    for(int i=1; i<=n; i++) cin>>a[i];

    int ub = k, mub = -1;
    for(int i=k; i<=ub; i++){
        ll dist = x[i] + a[i];
        int ub = upper_bound(all(x), dist) - x.begin() - 1;
        chmax(mub, ub);
    }

    int lb = k, mlb = n + 1;
    for(int i=k; i>=lb; i--){
        ll dist = x[i] - a[i];
        int lb = lower_bound(all(x), dist) - x.begin();
        chmin(mlb, lb);
    }

    cout << mub - mlb + 1 << endl;

    return 0;
}
0