結果

問題 No.2390 Udon Coupon (Hard)
ユーザー rniyarniya
提出日時 2023-07-21 22:04:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 299 ms / 2,000 ms
コード長 1,670 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 196,084 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 21:00:13
合計ジャッジ時間 14,077 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
5,248 KB
testcase_01 AC 201 ms
5,376 KB
testcase_02 AC 289 ms
5,376 KB
testcase_03 AC 291 ms
5,376 KB
testcase_04 AC 287 ms
5,376 KB
testcase_05 AC 30 ms
5,376 KB
testcase_06 AC 299 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 289 ms
5,376 KB
testcase_10 AC 67 ms
5,376 KB
testcase_11 AC 33 ms
5,376 KB
testcase_12 AC 58 ms
5,376 KB
testcase_13 AC 28 ms
5,376 KB
testcase_14 AC 65 ms
5,376 KB
testcase_15 AC 58 ms
5,376 KB
testcase_16 AC 169 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 33 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
testcase_20 AC 23 ms
5,376 KB
testcase_21 AC 24 ms
5,376 KB
testcase_22 AC 293 ms
5,376 KB
testcase_23 AC 294 ms
5,376 KB
testcase_24 AC 287 ms
5,376 KB
testcase_25 AC 297 ms
5,376 KB
testcase_26 AC 291 ms
5,376 KB
testcase_27 AC 298 ms
5,376 KB
testcase_28 AC 290 ms
5,376 KB
testcase_29 AC 285 ms
5,376 KB
testcase_30 AC 294 ms
5,376 KB
testcase_31 AC 290 ms
5,376 KB
testcase_32 AC 282 ms
5,376 KB
testcase_33 AC 289 ms
5,376 KB
testcase_34 AC 290 ms
5,376 KB
testcase_35 AC 289 ms
5,376 KB
testcase_36 AC 292 ms
5,376 KB
testcase_37 AC 285 ms
5,376 KB
testcase_38 AC 293 ms
5,376 KB
testcase_39 AC 225 ms
5,376 KB
testcase_40 AC 292 ms
5,376 KB
testcase_41 AC 295 ms
5,376 KB
testcase_42 AC 295 ms
5,376 KB
testcase_43 AC 296 ms
5,376 KB
testcase_44 AC 297 ms
5,376 KB
testcase_45 AC 296 ms
5,376 KB
testcase_46 AC 298 ms
5,376 KB
testcase_47 AC 287 ms
5,376 KB
testcase_48 AC 289 ms
5,376 KB
testcase_49 AC 23 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif

using namespace std;

typedef long long ll;
#define all(x) begin(x), end(x)
constexpr int INF = (1 << 30) - 1;
constexpr long long IINF = (1LL << 60) - 1;
constexpr int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

template <class T> istream& operator>>(istream& is, vector<T>& v) {
    for (auto& x : v) is >> x;
    return is;
}

template <class T> ostream& operator<<(ostream& os, const vector<T>& v) {
    auto sep = "";
    for (const auto& x : v) os << exchange(sep, " ") << x;
    return os;
}

template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x and (x = forward<U>(y), true); }

template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y and (x = forward<U>(y), true); }

template <class T> void mkuni(vector<T>& v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
}

template <class T> int lwb(const vector<T>& v, const T& x) { return lower_bound(begin(v), end(v), x) - begin(v); }

const int MAX = 3010;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vector<ll> A(3), B(3);
    for (int i = 0; i < 3; i++) cin >> A[i] >> B[i];

    ll ans = 0;
    for (int k = 0; k < 3; k++) {
        int p = k, q = (p + 1) % 3, r = (q + 1) % 3;
        for (int i = 0; i < MAX; i++) {
            for (int j = 0; j < MAX; j++) {
                ll rest = N - A[p] * i - A[q] * j;
                if (rest < 0) continue;
                chmax(ans, B[p] * i + B[q] * j + B[r] * (rest / A[r]));
            }
        }
    }

    cout << ans << '\n';
    return 0;
}
0