結果
| 問題 | No.808 Kaiten Sushi? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-22 02:18:47 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| + 34µs | |
| コード長 | 1,047 bytes |
| 記録 | |
| コンパイル時間 | 347 ms |
| コンパイル使用メモリ | 80,256 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-07-19 17:54:18 |
| 合計ジャッジ時間 | 5,562 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 100010;
struct Event {
int pos, type;
};
int n, l, x[N], y[N], cur, ma, mi, last, nxt, p, laps;
LL ans;
Event events[N * 2];
int main() {
scanf("%d%d", &n, &l);
for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
for (int i = 0; i < n; ++i) scanf("%d", &y[i]);
int xi = 0, yi = 0, idx = 0;
while (xi < n || yi < n) {
if (xi == n) events[idx++] = { y[yi++], -1 };
else if (yi == n) events[idx++] = { x[xi++], 1 };
else if (x[xi] < y[yi]) events[idx++] = { x[xi++], 1 };
else events[idx++] = { y[yi++], -1 };
}
cur = ma = 0, mi = n;
last = -1;
for (int i = 0; i < n * 2; ++i) {
cur += events[i].type;
if (cur >= ma) {
ma = cur;
last = i;
}
if (cur <= mi) mi = cur;
}
nxt = (last + 1) % (n * 2);
p = events[nxt].pos;
laps = ma - mi - (ma > 0 ? 1 : 0);
ans = 1LL * laps * l + p;
printf("%lld\n", ans);
return 0;
}