結果

問題 No.808 Kaiten Sushi?
ユーザー gazellegazelle
提出日時 2019-03-22 22:15:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,569 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 123,912 KB
実行使用メモリ 23,160 KB
最終ジャッジ日時 2023-10-19 09:35:42
合計ジャッジ時間 8,374 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
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.lower_bound(pos);
			if(ite == y.begin()) {
				tmp += pos + 1;
				pos = l - 1;
				ite = y.end();
				ite--;
			} else ite--;
			tmp += pos - *ite;
			pos = *ite;
			y.erase(ite);
			ite = x.lower_bound(pos);
			if(ite == x.begin()) {
				tmp += pos + 1;
				pos = l - 1;
				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