結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
noshi91
|
| 提出日時 | 2019-03-03 03:11:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 2,000 ms |
| コード長 | 993 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 72,780 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 01:20:12 |
| 合計ジャッジ時間 | 4,351 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include<cstddef>
#include<cstdint>
#include<iostream>
#include<limits>
#include<vector>
using isize = std::ptrdiff_t;
using usize = std::size_t;
using u64 = std::uint_fast64_t;
int main() {
usize N;
std::cin >> N;
u64 L;
std::cin >> L;
std::vector<u64> x(N);
for (auto &e : x) {
std::cin >> e;
}
std::vector<u64> y(N);
for (auto &e : y) {
std::cin >> e;
}
x.emplace_back(std::numeric_limits<u64>::max());
y.emplace_back(std::numeric_limits<u64>::max());
isize count = 0, max = 0, min = 0;
auto xitr = x.cbegin(), yitr = y.cbegin();
u64 last;
for (usize i = 0;i != N * 2;++i) {
if (*xitr < *yitr) {
++count;
if (max <= count) {
max = count;
last = *yitr;
}
++xitr;
}
else {
--count;
if (count <= min) {
min = count;
}
++yitr;
}
}
const usize diff = max - min;
u64 ans;
if (max == static_cast<isize>(0)) {
ans = L*diff + y.front();
}
else {
ans = L*diff - (L - last);
}
std::cout << ans << std::endl;
return 0;
}
noshi91