結果
問題 |
No.808 Kaiten Sushi?
|
ユーザー |
![]() |
提出日時 | 2019-03-22 22:27:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 51,200 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 05:56:47 |
合計ジャッジ時間 | 2,557 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 56 |
ソースコード
#include<cstddef> #include<cstdint> #include<cstdio> #include<limits> #include<vector> using isize = int; using usize = unsigned int; using u64 = unsigned long long; int main() { usize N; u64 L; scanf("%u%llu", &N, &L); std::vector<u64> x(N); for (auto &e : x) { scanf("%llu", &e); } std::vector<u64> y(N); for (auto &e : y) { scanf("%llu", &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); } printf("%llu\n", ans); return 0; }