結果

問題 No.808 Kaiten Sushi?
ユーザー gazellegazelle
提出日時 2019-03-22 22:18:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 124,032 KB
実行使用メモリ 23,204 KB
最終ジャッジ日時 2023-10-19 09:36:39
合計ジャッジ時間 8,230 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 13 ms
4,348 KB
testcase_08 AC 15 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 28 ms
4,348 KB
testcase_11 AC 21 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 32 ms
4,348 KB
testcase_17 AC 8 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 6 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 725 ms
10,880 KB
testcase_24 AC 482 ms
9,464 KB
testcase_25 AC 614 ms
10,428 KB
testcase_26 AC 542 ms
10,060 KB
testcase_27 TLE -
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 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, l;
	cin >> n >> l;
	set<ll> xx, yy;
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		xx.insert(tmp);
	}
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		yy.insert(tmp);
	}
	ll lb = 0, ub = INF * INF;
	while(ub - lb > 1) {
		ll m = (ub + lb) / 2;
		ll pos = m % l, tmp = 0;
		set<ll> x = xx, y = yy;
		REP(i, n) {
			auto ite = y.upper_bound(pos);
			if(ite == y.begin()) {
				tmp += pos;
				pos = l;
				ite = y.end();
				ite--;
			} else ite--;
			tmp += pos - *ite;
			pos = *ite;
			y.erase(ite);
			ite = x.upper_bound(pos);
			if(ite == x.begin()) {
				tmp += pos;
				pos = l;
				ite = x.end();
				ite--;
			} else ite--;
			tmp += pos - *ite;
			pos = *ite;
			x.erase(ite);
		}
		tmp += pos;
		if(tmp > m) lb = m;
		else ub = m;
	}
	cout << ub << endl;
	return 0;
}

/* --------------------------------------- */
0