結果

問題 No.808 Kaiten Sushi?
ユーザー startcppstartcpp
提出日時 2019-03-22 23:58:23
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,169 bytes
コンパイル時間 1,034 ms
コンパイル使用メモリ 93,832 KB
実行使用メモリ 17,596 KB
最終ジャッジ日時 2023-08-20 12:10:01
合計ジャッジ時間 21,208 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 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 7 ms
4,384 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 18 ms
4,380 KB
testcase_10 AC 12 ms
4,384 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 12 ms
4,384 KB
testcase_13 AC 10 ms
4,384 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 14 ms
4,384 KB
testcase_17 AC 5 ms
4,384 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 4 ms
4,384 KB
testcase_23 AC 417 ms
7,624 KB
testcase_24 AC 310 ms
6,784 KB
testcase_25 AC 356 ms
7,320 KB
testcase_26 AC 330 ms
7,164 KB
testcase_27 AC 1,626 ms
12,432 KB
testcase_28 AC 284 ms
6,112 KB
testcase_29 AC 1,529 ms
12,060 KB
testcase_30 AC 674 ms
8,992 KB
testcase_31 AC 1,707 ms
12,896 KB
testcase_32 AC 1,910 ms
14,148 KB
testcase_33 AC 795 ms
8,864 KB
testcase_34 AC 890 ms
9,800 KB
testcase_35 AC 1,277 ms
11,160 KB
testcase_36 AC 815 ms
8,824 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 TLE -
testcase_40 AC 279 ms
5,840 KB
testcase_41 AC 302 ms
6,120 KB
testcase_42 AC 1,805 ms
11,644 KB
testcase_43 AC 434 ms
6,952 KB
testcase_44 AC 1,218 ms
9,780 KB
testcase_45 AC 469 ms
7,056 KB
testcase_46 AC 198 ms
5,472 KB
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 AC 1,004 ms
11,220 KB
testcase_53 AC 1,416 ms
14,180 KB
testcase_54 AC 2 ms
4,384 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,384 KB
testcase_57 AC 386 ms
7,140 KB
testcase_58 AC 655 ms
9,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <set>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, l;
int x[100000];
int y[100000];

int simurate(int last) {
	set<int> A;
	set<int> B;
	set<int>::iterator it;
	int i;
	
	rep(i, n) if (i > 0) A.insert(x[i]);
	rep(i, n) if (i != last) B.insert(y[i]);
	
	int now = x[0];
	int ret = 0;
	
	rep(i, 2 * n - 2) {
		if (i % 2 == 0) {
			it = B.lower_bound(now);
			if (it == B.end())
				it = B.lower_bound(0);
			int nxt = (*it);
			if (nxt < now) {
				ret++;
			}
			B.erase(it);
			now = nxt;
		}
		else {
			it = A.lower_bound(now);
			if (it == A.end())
				it = A.lower_bound(0);
			int nxt = (*it);
			if (nxt < now) {
				ret++;
			}
			A.erase(it);
			now = nxt;
		}
	}
	
	if (y[last] < now) ret++;
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> l;
	rep(i, n) cin >> x[i];
	rep(i, n) cin >> y[i];
	
	int okimoti = simurate(n - 1);
	int st = -1, ed = n - 1, mid;	//(st, ed], xxxooo
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (simurate(mid) > okimoti) st = mid;
		else ed = mid;
	}
	
	int ans = simurate(ed) * l + y[ed];
	cout << ans << endl;
	return 0;
}
0