結果

問題 No.1460 Max of Min
ユーザー Mister
提出日時 2021-03-31 22:02:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 719 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 73,580 KB
最終ジャッジ日時 2025-01-20 03:34:08
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 87 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>
#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;

    for (int i = k; i < k * 1000; ++i) {
        lint ma = -INF;
        for (int j = 1; j <= k; ++j) {
            ma = max(ma, min(xs[i - j], ys[k - j]));
        }
        xs.push_back(ma);
    }

    if (n < (int)xs.size()) {
        cout << xs[n] << "\n";
    } else {
        cout << xs[k * 999 + n % k] << "\n";
    }
}

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

    solve();

    return 0;
}
0