結果

問題 No.2386 Udon Coupon (Easy)
ユーザー AC2KAC2K
提出日時 2023-07-21 21:24:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 3,613 bytes
コンパイル時間 4,085 ms
コンパイル使用メモリ 251,688 KB
実行使用メモリ 17,156 KB
最終ジャッジ日時 2023-10-21 21:11:34
合計ジャッジ時間 8,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 189 ms
17,156 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 30 ms
6,836 KB
testcase_11 AC 9 ms
5,032 KB
testcase_12 AC 132 ms
13,764 KB
testcase_13 AC 183 ms
16,624 KB
testcase_14 AC 154 ms
14,852 KB
testcase_15 AC 181 ms
16,544 KB
testcase_16 AC 122 ms
13,152 KB
testcase_17 AC 164 ms
15,520 KB
testcase_18 AC 50 ms
8,616 KB
testcase_19 AC 6 ms
4,536 KB
testcase_20 AC 112 ms
12,500 KB
testcase_21 AC 164 ms
15,444 KB
testcase_22 AC 81 ms
10,448 KB
testcase_23 AC 71 ms
9,796 KB
testcase_24 AC 16 ms
5,676 KB
testcase_25 AC 104 ms
11,852 KB
testcase_26 AC 161 ms
15,080 KB
testcase_27 AC 192 ms
16,856 KB
testcase_28 AC 73 ms
9,940 KB
testcase_29 AC 34 ms
7,220 KB
testcase_30 AC 4 ms
4,364 KB
testcase_31 AC 67 ms
9,548 KB
testcase_32 AC 6 ms
4,624 KB
testcase_33 AC 194 ms
17,140 KB
testcase_34 AC 82 ms
10,540 KB
testcase_35 AC 123 ms
13,336 KB
testcase_36 AC 183 ms
16,676 KB
testcase_37 AC 134 ms
13,688 KB
testcase_38 AC 92 ms
11,228 KB
testcase_39 AC 55 ms
8,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 2 "library/src/stream.hpp"
#include <ctype.h>
#include <stdio.h>
#include <string>
namespace kyopro {
/**
 * 文字を1個読み込む
 */
inline char readchar() {
    char c = getchar_unlocked();
    while (isspace(c)) c = getchar_unlocked();
    return c;
}
/**
 *  整数の入出力
 */
template <typename T> constexpr inline void readint(T& a) {
    a = 0;
    bool is_negative = false;
    char c = getchar_unlocked();
    while (isspace(c)) {
        c = getchar_unlocked();
    }
    if (c == '-') is_negative = true, c = getchar_unlocked();
    while (isdigit(c)) {
        a = 10 * a + (c - '0');
        c = getchar_unlocked();
    }
    if (is_negative) a *= -1;
}
template <typename Head, typename... Tail>
constexpr inline void readint(Head& head, Tail&... tail) {
    readint(head);
    readint(tail...);
}

template <typename T> void write_int(T a) {
    if (!a) {
        putchar_unlocked('0');
        putchar_unlocked('\n');
        return;
    }
    if (a < 0) putchar_unlocked('-'), a *= -1;
    char s[37];
    int now = 37;
    while (a) {
        s[--now] = (char)'0' + a % 10;
        a /= 10;
    }
    while (now < 37) putchar_unlocked(s[now++]);
}
template <typename T> constexpr inline void putint(T a) {
    if (!a) {
        putchar_unlocked('0');
        putchar_unlocked('\n');
        return;
    }
    if (a < 0) putchar_unlocked('-'), a *= -1;
    char s[37];
    int now = 37;
    while (a) {
        s[--now] = (char)'0' + a % 10;
        a /= 10;
    }
    while (now < 37) putchar_unlocked(s[now++]);
    putchar_unlocked('\n');
}
template <typename Head, typename... Tail>
constexpr inline void putint(Head head, Tail... tail) {
    putint(head);
    putint(tail...);
}

/**
 * 文字列の入出力
 */

inline void readstr(std::string& str) {
    char c = getchar_unlocked();
    while (isspace(c)) c = getchar_unlocked();
    while (!isspace(c)) {
        str += c;
        c = getchar_unlocked();
    }
}

inline void readstr(std::string& str,std::string& tail...) {
    readstr(str);
    readstr(tail);
}
inline void putstr(const std::string& str) {
    for (auto c : str) {
        putchar_unlocked(c);
    }
    putchar_unlocked('\n');
}
inline void putstr(const std::string& str, const std::string& tail...) {
    putstr(str);
    putstr(tail);
}
};  // namespace kyopro

/**
 * @brief fastIO
 */
#line 2 "library/src/template.hpp"
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(x) std::begin(x), std::end(x)
#define popcount(x) __builtin_popcountll(x)
using i128 = __int128_t;
using ll = long long;
using ld = long double;
using graph = std::vector<std::vector<int>>;
using P = std::pair<int, int>;
constexpr int inf = 1e9;
constexpr ll infl = 1e18;
constexpr ld eps = 1e-12;
const long double pi = acosl(-1);
constexpr uint64_t MOD = 1e9 + 7;
constexpr uint64_t MOD2 = 998244353;
constexpr int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1, 0};
constexpr int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1, 0};
template <typename T1, typename T2> constexpr inline bool chmax(T1& a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> constexpr inline bool chmin(T1& a, T2 b) {
    return a > b && (a = b, true);
}
#line 3 "a.cpp"

using namespace std;
using namespace kyopro;

int n, a, b, c;
map<int, int> memo;
int f(int x){
    if (x == 0) return 0;
    if (memo.count(x)) return memo[x];

    if (x >= 3) chmax(memo[x], a + f(x - 3));
    if (x >= 5) chmax(memo[x], b + f(x - 5));
    if (x >= 10) chmax(memo[x], c + f(x - 10));

    return memo[x];
}
int main() {
    readint(n, a, b, c);
    putint(f(n));
}
0