結果

問題 No.808 Kaiten Sushi?
ユーザー noshi91noshi91
提出日時 2019-03-03 03:11:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 73,040 KB
実行使用メモリ 5,552 KB
最終ジャッジ日時 2023-10-12 01:29:30
合計ジャッジ時間 4,343 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 4 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 3 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 29 ms
4,352 KB
testcase_24 AC 24 ms
4,348 KB
testcase_25 AC 25 ms
4,352 KB
testcase_26 AC 24 ms
4,352 KB
testcase_27 AC 61 ms
5,124 KB
testcase_28 AC 20 ms
4,476 KB
testcase_29 AC 61 ms
5,024 KB
testcase_30 AC 36 ms
4,372 KB
testcase_31 AC 64 ms
5,104 KB
testcase_32 AC 73 ms
5,412 KB
testcase_33 AC 37 ms
4,352 KB
testcase_34 AC 41 ms
4,360 KB
testcase_35 AC 51 ms
4,904 KB
testcase_36 AC 38 ms
4,352 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,352 KB
testcase_39 AC 66 ms
5,224 KB
testcase_40 AC 17 ms
4,352 KB
testcase_41 AC 20 ms
4,352 KB
testcase_42 AC 55 ms
4,892 KB
testcase_43 AC 25 ms
4,352 KB
testcase_44 AC 43 ms
4,416 KB
testcase_45 AC 26 ms
4,352 KB
testcase_46 AC 15 ms
4,352 KB
testcase_47 AC 73 ms
5,428 KB
testcase_48 AC 73 ms
5,548 KB
testcase_49 AC 73 ms
5,424 KB
testcase_50 AC 73 ms
5,552 KB
testcase_51 AC 74 ms
5,416 KB
testcase_52 AC 53 ms
4,792 KB
testcase_53 AC 71 ms
5,372 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 2 ms
4,352 KB
testcase_57 AC 22 ms
4,352 KB
testcase_58 AC 39 ms
4,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstddef>
#include<cstdint>
#include<iostream>
#include<limits>
#include<vector>

using isize = std::ptrdiff_t;
using usize = std::size_t;
using u64 = std::uint_fast64_t;

int main() {
	usize N;
	std::cin >> N;
	u64 L;
	std::cin >> L;
	std::vector<u64> x(N);
	for (auto &e : x) {
		std::cin >> e;
	}
	std::vector<u64> y(N);
	for (auto &e : y) {
		std::cin >> e;
	}

	x.emplace_back(std::numeric_limits<u64>::max());
	y.emplace_back(std::numeric_limits<u64>::max());

	isize count = 0, max = 0, min = 0;
	auto xitr = x.cbegin(), yitr = y.cbegin();
	u64 last;
	for (usize i = 0;i != N * 2;++i) {
		if (*xitr < *yitr) {
			++count;
			if (max <= count) {
				max = count;
				last = *yitr;
			}
			++xitr;
		}
		else {
			--count;
			if (count <= min) {
				min = count;
			}
			++yitr;
		}
	}
	const usize diff = max - min;
	u64 ans;
	if (max == static_cast<isize>(0)) {
		ans = L*diff + y.front();
	}
	else {
		ans = L*diff - (L - last);
	}
	std::cout << ans << std::endl;
	return 0;
}
0