結果
問題 | No.808 Kaiten Sushi? |
ユーザー | Tiramister |
提出日時 | 2019-03-22 22:32:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 599 ms / 2,000 ms |
コード長 | 4,791 bytes |
コンパイル時間 | 1,128 ms |
コンパイル使用メモリ | 114,736 KB |
実行使用メモリ | 10,372 KB |
最終ジャッジ日時 | 2024-09-19 06:01:13 |
合計ジャッジ時間 | 14,393 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 9 ms
6,940 KB |
testcase_08 | AC | 11 ms
6,940 KB |
testcase_09 | AC | 17 ms
6,940 KB |
testcase_10 | AC | 11 ms
6,944 KB |
testcase_11 | AC | 9 ms
6,944 KB |
testcase_12 | AC | 12 ms
6,944 KB |
testcase_13 | AC | 10 ms
6,944 KB |
testcase_14 | AC | 5 ms
6,944 KB |
testcase_15 | AC | 16 ms
6,940 KB |
testcase_16 | AC | 13 ms
6,940 KB |
testcase_17 | AC | 6 ms
6,940 KB |
testcase_18 | AC | 4 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 4 ms
6,944 KB |
testcase_21 | AC | 3 ms
6,944 KB |
testcase_22 | AC | 4 ms
6,940 KB |
testcase_23 | AC | 231 ms
6,944 KB |
testcase_24 | AC | 181 ms
6,944 KB |
testcase_25 | AC | 210 ms
6,944 KB |
testcase_26 | AC | 196 ms
6,944 KB |
testcase_27 | AC | 526 ms
9,916 KB |
testcase_28 | AC | 151 ms
6,940 KB |
testcase_29 | AC | 478 ms
8,724 KB |
testcase_30 | AC | 312 ms
6,940 KB |
testcase_31 | AC | 532 ms
9,576 KB |
testcase_32 | AC | 599 ms
9,792 KB |
testcase_33 | AC | 285 ms
7,032 KB |
testcase_34 | AC | 350 ms
7,672 KB |
testcase_35 | AC | 403 ms
8,104 KB |
testcase_36 | AC | 298 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 543 ms
10,356 KB |
testcase_40 | AC | 132 ms
6,944 KB |
testcase_41 | AC | 145 ms
6,944 KB |
testcase_42 | AC | 434 ms
8,716 KB |
testcase_43 | AC | 191 ms
6,944 KB |
testcase_44 | AC | 353 ms
7,040 KB |
testcase_45 | AC | 190 ms
6,940 KB |
testcase_46 | AC | 110 ms
6,940 KB |
testcase_47 | AC | 584 ms
10,372 KB |
testcase_48 | AC | 574 ms
9,736 KB |
testcase_49 | AC | 576 ms
9,860 KB |
testcase_50 | AC | 594 ms
9,720 KB |
testcase_51 | AC | 588 ms
10,116 KB |
testcase_52 | AC | 399 ms
8,396 KB |
testcase_53 | AC | 553 ms
10,304 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,940 KB |
testcase_56 | AC | 2 ms
6,944 KB |
testcase_57 | AC | 193 ms
6,940 KB |
testcase_58 | AC | 297 ms
6,940 KB |
ソースコード
// IO library #include <cstdio> #include <iomanip> #include <ios> #include <iostream> // algorithm library #include <algorithm> #include <cmath> #include <numeric> #include <random> // contancer library #include <bitset> #include <deque> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> #include <functional> #include <limits> using ll = long long; using ld = long double; /* ----- Output Functions for Debugging ----- */ template <class T> std::ostream& operator<<(std::ostream& os, std::vector<T> v); template <class T> std::ostream& operator<<(std::ostream& os, std::set<T> v); template <class L, class R> std::ostream& operator<<(std::ostream& os, std::pair<L, R> p); template <class K, class T> std::ostream& operator<<(std::ostream& os, std::map<K, T> v); template <class T> std::ostream& operator<<(std::ostream& os, std::queue<T> q); template <class T> std::ostream& operator<<(std::ostream& os, std::priority_queue<T> q); template <class T> std::ostream& operator<<(std::ostream& os, std::vector<T> v) { os << "["; for (auto vv : v) os << vv << ","; return os << "]"; } template <class T> std::ostream& operator<<(std::ostream& os, std::set<T> v) { os << "{"; for (auto vv : v) os << vv << ","; return os << "}"; } template <class L, class R> std::ostream& operator<<(std::ostream& os, std::pair<L, R> p) { return os << "(" << p.first << "," << p.second << ")"; } template <class K, class T> std::ostream& operator<<(std::ostream& os, std::map<K, T> v) { os << "{"; for (auto vv : v) os << vv << ","; return os << "}"; } template <class T> std::ostream& operator<<(std::ostream& os, std::queue<T> q) { os << "["; while (!q.empty()) { os << q.front() << ","; q.pop(); } return os << "]"; } template <class T> std::ostream& operator<<(std::ostream& os, std::priority_queue<T> q) { os << "{"; while (!q.empty()) { os << q.top() << ","; q.pop(); } return os << "}"; } /* ----- Short Functions ----- */ template <class T> T Vec(T v) { return v; } template <class T, class... Ts> auto Vec(size_t l, Ts... ts) { return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...)); } template <class T> inline T sq(T a) { return a * a; } template <class T> inline T iceil(T n, T d) { return (n + d - 1) / d; } template <class T> T gcd(T a, T b) { while (b > 0) { a %= b; swap(a, b); } return a; } template <class T, class U> T ipow(T b, U n) { T ret = 1; while (n > 0) { if (n & 1) ret *= b; n >>= 1; b *= b; } return ret; } // 0-indexed template <class T, class U> inline T kthbit(T a, U k) { return (a >> k) & 1; } template <class T, class U> inline T mask(T a, U k) { return a & ((1 << k) - 1); } /* ----- class ----- */ template <class T> struct Edge { int from, to; T cost; Edge(int from = -1, int to = -1, T cost = 1) : from(from), to(to), cost(cost){}; bool operator<(const Edge<T>& e) const { return this->cost < e.cost; } bool operator>(const Edge<T>& e) const { return this->cost > e.cost; } }; template <class T = int> class Graph { public: explicit Graph(int N = 0) : size(N) { path.resize(size); } void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(u, v, cost)); } std::vector<Edge<T>> operator[](int v) const { return path[v]; } int size; std::vector<std::vector<Edge<T>>> path; }; /* ----- Constants ----- */ // const int INF = 1 << 25; // const ll INF = 1LL << 50; // const ld PI = acos(-1); // const ld EPS = 1e-10; // mt19937 mt(ll(time(0))); int main() { int N; ll L; std::cin >> N >> L; std::vector<std::pair<ll, int>> pos(N * 2); for (int i = 0; i < N; ++i) { std::cin >> pos[i].first; pos[i].second = 1; } for (int i = 0; i < N; ++i) { std::cin >> pos[i + N].first; pos[i + N].second = -1; } std::sort(pos.begin(), pos.end()); int bitr = 0; while (pos[bitr].second < 0) ++bitr; ll buf = pos[bitr].first; for (auto& p : pos) { p.first -= buf; if (p.first < 0) p.first += L; } std::sort(pos.begin(), pos.end()); pos.push_back(pos.front()); std::vector<ll> sushi(N * 2 + 1); sushi[0] = 0; for (int i = 0; i < N * 2; ++i) { sushi[i + 1] = sushi[i] + pos[i].second; } ll min = *std::min_element(sushi.begin(), sushi.end()); for (auto& s : sushi) s -= min; std::cerr << sushi << std::endl; ll ans = 0; for (int i = 1; i <= N * 2; ++i) { if (pos[i].second < 0) { ans = std::max(ans, pos[i].first + L * (sushi[i] - 1)); } } std::cout << ans + buf << std::endl; return 0; }