結果

問題 No.871 かえるのうた
ユーザー data9824data9824
提出日時 2019-09-14 02:53:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 955 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 65,624 KB
実行使用メモリ 4,720 KB
最終ジャッジ日時 2023-09-18 01:14:45
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> x(n), a(n);
	vector<bool> sung(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sung[k - 1] = true;
	for (;;) {
		bool newlySung = false;
		for (int i = 0; i < n; ++i) {
			if (sung[i]) {
				long long frontX = x[i] - a[i];
				long long backX = x[i] + a[i];
				for (int frontIndex = i;
					frontIndex >= 0 && frontX <= x[frontIndex];
					--frontIndex) {
					if (!sung[frontIndex]) {
						newlySung = true;
						sung[frontIndex] = true;
					}
				}
				for (int backIndex = i;
					backIndex < n && x[backIndex] <= backX;
					++backIndex) {
					if (!sung[backIndex]) {
						newlySung = true;
						sung[backIndex] = true;
					}
				}
			}
		}
		if (!newlySung) {
			break;
		}
	}
	cout << count(sung.begin(), sung.end(), true) << endl;
	return 0;
}
0