結果

問題 No.1460 Max of Min
ユーザー MisterMister
提出日時 2021-04-01 07:32:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,017 bytes
コンパイル時間 1,388 ms
コンパイル使用メモリ 88,324 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 12:48:41
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 83 ms
4,380 KB
testcase_04 AC 110 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 131 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 142 ms
4,380 KB
testcase_11 AC 28 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 8 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 7 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 5 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 9 ms
4,380 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 3 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 7 ms
4,376 KB
testcase_38 WA -
testcase_39 AC 4 ms
4,376 KB
testcase_40 AC 4 ms
4,384 KB
testcase_41 AC 4 ms
4,380 KB
testcase_42 AC 4 ms
4,376 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 8 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 5 ms
4,380 KB
testcase_47 AC 6 ms
4,376 KB
testcase_48 AC 8 ms
4,376 KB
testcase_49 WA -
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 5 ms
4,376 KB
testcase_52 AC 3 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 16 ms
4,380 KB
testcase_55 AC 12 ms
4,380 KB
testcase_56 WA -
testcase_57 AC 8 ms
4,380 KB
testcase_58 AC 7 ms
4,380 KB
testcase_59 AC 7 ms
4,376 KB
testcase_60 AC 11 ms
4,376 KB
testcase_61 AC 17 ms
4,376 KB
testcase_62 AC 15 ms
4,376 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 8 ms
4,376 KB
testcase_66 AC 12 ms
4,380 KB
testcase_67 WA -
testcase_68 AC 10 ms
4,376 KB
testcase_69 AC 11 ms
4,380 KB
testcase_70 AC 14 ms
4,376 KB
testcase_71 AC 7 ms
4,380 KB
testcase_72 AC 14 ms
4,376 KB
testcase_73 AC 18 ms
4,376 KB
testcase_74 AC 15 ms
4,376 KB
testcase_75 AC 18 ms
4,376 KB
testcase_76 AC 14 ms
4,376 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 109 ms
4,376 KB
testcase_85 AC 110 ms
4,376 KB
testcase_86 AC 105 ms
4,380 KB
testcase_87 AC 112 ms
4,376 KB
testcase_88 AC 106 ms
4,380 KB
testcase_89 AC 111 ms
4,376 KB
testcase_90 AC 117 ms
4,380 KB
testcase_91 AC 116 ms
4,376 KB
testcase_92 AC 108 ms
4,380 KB
testcase_93 AC 109 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 2 "/Users/tiramister/CompetitiveProgramming/Cpp/CppLibrary/Tools/heap_alias.hpp"

#include <queue>

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
#line 2 "main.cpp"
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int k;
    lint n;
    cin >> k >> n;

    vector<lint> xs(k), ys(k);
    for (auto& x : xs) cin >> x;
    for (auto& y : ys) cin >> y;

    if (n < k) {
        cout << xs[n] << "\n";
        return;
    }

    lint ok = -INF, ng = INF;
    while (ng - ok > 1) {
        auto mid = (ok + ng) / 2;

        vector<int> ts;  // { k-j | ys[j] >= mid }
        for (int j = 0; j < k; ++j) {
            if (ys[j] >= mid) ts.push_back(k - j);
        }
        if (ts.empty()) {
            ng = mid;
            continue;
        }

        auto m = ts.back();  // minimum
        while (m < k) m <<= 1;
        // 小さすぎると遷移できない場合があるので、十分に拡張

        // mod m でDijkstra
        vector<lint> dist(m, INF);
        MinHeap<pair<lint, int>> heap;
        for (int i = 0; i < k; ++i) {
            if (xs[i] >= mid) {
                dist[i] = i;
                heap.emplace(i, i);
            }
        }

        while (!heap.empty()) {
            auto [d, i] = heap.top();
            heap.pop();
            if (d > dist[i]) continue;

            for (auto t : ts) {
                auto ni = (i + t) % m;
                auto nd = d + t;

                if (nd < dist[ni]) {
                    dist[ni] = nd;
                    heap.emplace(nd, ni);
                }
            }
        }

        if (dist[n % m] <= n) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0