結果

問題 No.871 かえるのうた
ユーザー sprng_wlsprng_wl
提出日時 2019-08-30 21:45:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 160,224 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 17:09:55
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 118 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 105 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 11 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 38 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 21 ms
5,376 KB
testcase_35 WA -
testcase_36 AC 77 ms
5,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 31 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 WA -
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<Int> x(N + 1), a(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> x[i]; }
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }

	int kl = K, kr = K;
	Int xl = x[K] - a[K], xr = x[K] + a[K];
	bool update = false;
	while (true) {
		update = false;
		while (kl - 1 > 0) {
			if (x[kl - 1] < xl || x[kl - 1] > xr) { break; }
			--kl;
			xl = min(xl, x[kl] - a[kl]);
			xr = max(xr, x[kl] + a[kl]);
			update = true;
		}
		while (kr < N) {
			if (x[kr + 1] < xl || x[kr + 1] > xr) { break; }
			++kr;
			xl = min(xl, x[kr] - a[kr]);
			xr = max(xr, x[kr] - a[kr]);
			update = true;
		}
		if (!update) { break; }
	}
	cout << kr - kl + 1 << endl;

	return 0;
}
0