結果

問題 No.808 Kaiten Sushi?
ユーザー FF256grhyFF256grhy
提出日時 2019-03-22 23:23:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 2,417 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 175,284 KB
実行使用メモリ 9,700 KB
最終ジャッジ日時 2023-10-19 10:47:34
合計ジャッジ時間 5,382 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 35 ms
5,928 KB
testcase_24 AC 28 ms
5,324 KB
testcase_25 AC 30 ms
5,888 KB
testcase_26 AC 30 ms
5,860 KB
testcase_27 AC 73 ms
9,436 KB
testcase_28 AC 24 ms
4,972 KB
testcase_29 AC 69 ms
9,372 KB
testcase_30 AC 44 ms
6,416 KB
testcase_31 AC 76 ms
9,496 KB
testcase_32 AC 86 ms
9,676 KB
testcase_33 AC 45 ms
6,408 KB
testcase_34 AC 48 ms
7,060 KB
testcase_35 AC 60 ms
9,252 KB
testcase_36 AC 45 ms
6,392 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 79 ms
9,572 KB
testcase_40 AC 19 ms
4,660 KB
testcase_41 AC 23 ms
4,968 KB
testcase_42 AC 66 ms
9,324 KB
testcase_43 AC 31 ms
5,844 KB
testcase_44 AC 51 ms
7,060 KB
testcase_45 AC 31 ms
5,844 KB
testcase_46 AC 18 ms
4,568 KB
testcase_47 AC 87 ms
9,700 KB
testcase_48 AC 86 ms
9,700 KB
testcase_49 AC 86 ms
9,700 KB
testcase_50 AC 86 ms
9,700 KB
testcase_51 AC 87 ms
9,700 KB
testcase_52 AC 63 ms
9,260 KB
testcase_53 AC 84 ms
9,676 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 28 ms
5,868 KB
testcase_58 AC 47 ms
6,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

LL n, l, x[100001], y[100001];
vector<pair<LL, LL>> v;

int main() {
	cin >> n >> l;
	inc(i, n) { cin >> x[i]; }
	inc(i, n) { cin >> y[i]; }
	x[n] = y[n] = 2e9;
	
	int i = 0;
	int j = 0;
	while(true) {
		bool I = (j == n);
		bool J = (i == n);
		if(I && J) { break; }
		bool f = (I || J ? I : x[i] < y[j]);
		if(f) { v.EB(+1, x[i]); i++; }
		else  { v.EB(-1, y[j]); j++; }
	}
	auto p = v[0];
	p.SE += l;
	v.PB(p);
	
	vector<LL> s(2 * n + 1);
	inc(i, 2 * n) { s[i + 1] = s[i] + v[i].FI; }
	
	pair<LL, int> mi = MP(0, 0), ma = MP(0, 0);
	LL c = 0;
	inc(i, 2 * n + 1) {
		setmin(mi, MP(c, i));
		setmax(ma, MP(c, i));
		c += v[i].FI;
	}
	
	LL ans = (ma.FI - mi.FI - 1) * l + v[ma.SE].SE;
	
	cout << ans << endl;
	
	return 0;
}
0