結果

問題 No.871 かえるのうた
ユーザー kenta255kenta255
提出日時 2019-08-30 21:37:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,155 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 203,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 16:57:38
合計ジャッジ時間 5,087 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 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 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 120 ms
5,376 KB
testcase_15 AC 119 ms
5,376 KB
testcase_16 AC 136 ms
5,376 KB
testcase_17 AC 104 ms
5,376 KB
testcase_18 AC 19 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 46 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 7 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 37 ms
5,376 KB
testcase_30 AC 73 ms
5,376 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 59 ms
5,376 KB
testcase_33 WA -
testcase_34 AC 21 ms
5,376 KB
testcase_35 AC 54 ms
5,376 KB
testcase_36 AC 75 ms
5,376 KB
testcase_37 AC 49 ms
5,376 KB
testcase_38 AC 110 ms
5,376 KB
testcase_39 WA -
testcase_40 AC 36 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 35 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))




int main(){
	ll N,K;
	cin >> N >> K;
	K--;
	vector<ll> X(N),A(N);
	FOR(i,0,N)cin>>X[i];
	FOR(i,0,N)cin>>A[i];
	ll L=K,R=K;
	FOR(i,K,N){
		if(i<=R){
			ll B = POSU(X,X[i]+A[i]) - 1;
			R = max(R,B);
		}
	}
	FORR(i,0,K+1){
		if(i>=L){
			ll B = POSL(X,X[i]-A[i]);
			L = min(L,B);
		}
	}
	cout << R-L+1 << endl;
}
0