結果

問題 No.808 Kaiten Sushi?
ユーザー ats5515ats5515
提出日時 2019-03-22 22:43:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,055 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 91,212 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-10-19 09:55:35
合計ジャッジ時間 3,571 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 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 16 ms
5,860 KB
testcase_24 AC 12 ms
4,692 KB
testcase_25 AC 14 ms
5,820 KB
testcase_26 AC 14 ms
5,788 KB
testcase_27 AC 35 ms
10,160 KB
testcase_28 AC 12 ms
4,604 KB
testcase_29 AC 33 ms
9,824 KB
testcase_30 AC 22 ms
6,052 KB
testcase_31 AC 36 ms
10,216 KB
testcase_32 AC 40 ms
10,664 KB
testcase_33 AC 21 ms
6,044 KB
testcase_34 AC 24 ms
6,164 KB
testcase_35 AC 29 ms
9,704 KB
testcase_36 AC 22 ms
6,028 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 36 ms
10,288 KB
testcase_40 AC 9 ms
4,556 KB
testcase_41 AC 11 ms
4,596 KB
testcase_42 AC 30 ms
9,784 KB
testcase_43 AC 15 ms
5,772 KB
testcase_44 AC 23 ms
6,164 KB
testcase_45 AC 15 ms
5,772 KB
testcase_46 AC 9 ms
4,500 KB
testcase_47 AC 39 ms
10,696 KB
testcase_48 AC 40 ms
10,696 KB
testcase_49 AC 39 ms
10,696 KB
testcase_50 AC 39 ms
10,696 KB
testcase_51 AC 39 ms
10,696 KB
testcase_52 AC 30 ms
9,712 KB
testcase_53 AC 39 ms
10,664 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 14 ms
5,796 KB
testcase_58 AC 24 ms
6,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L;
	cin >> N >> L;
	vector<int> A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	vector<pair<int, int> > vp;
	for (int i = 0; i < N; i++) {
		vp.emplace_back(A[i], i);
		vp.emplace_back(B[i], i + N);
	}

	sort(vp.begin(), vp.end());
	int cur = 0;
	N = 2 * N;
	res = -(1ll << 50);
	for (int ii = 0; ii < N; ii++) {
		int i = ii % N;

		//cerr << vp[i].first << " " << vp[i].second << endl;
		if (vp[i].second < N / 2) {
			cur++;
		}
		else {
			cur--;
			if (cur < 0){
				cur = 0;
				res = max(res, vp[i].first);
				res += L;
				
			}
			else {
				int tmp = cur * L + vp[i].first;
				res = max(res, tmp);
			}
		}
	}








	cout << res << endl;
}
0