結果

問題 No.1792 科学の甲子園
ユーザー 👑 hitonanodehitonanode
提出日時 2021-12-21 00:10:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 4,000 ms
コード長 1,462 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 96,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 01:28:49
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 5 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3,unroll-loops")
#include <iostream>
#include <vector>
using namespace std;
using lint = long long;

template <typename T> bool chmax(T &m, const T q) { return m < q ? (m = q, true) : false; }
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

template <typename T> T rd_integer() {
    T ret = 0;
    bool minus = false;

    char c = getchar_unlocked();
    while (!isdigit(c)) minus |= (c == '-'), c = getchar_unlocked();
    while (isdigit(c)) ret = (ret << 1) + (ret << 3) + (c ^ 48), c = getchar_unlocked();

    return minus ? -ret : ret;
}
int rdi() { return rd_integer<int>(); }

int main() {
    constexpr int D = 6;
    vector dp(5, vector<lint>(1 << D, 1));

    int N = rdi();
    vector<lint> V(D);
    vector<lint> tmp(1 << D, 1);

    vector<short> first_digit(1 << D);
    FOR(s, 1, 1 << D) first_digit[s] = __builtin_ctz(s);

    while (N--) {
        for (auto &x : V) x = rdi();
        FOR(s, 1, 1 << D) tmp[s] = tmp[s - (1 << first_digit[s])] * V[first_digit[s]];
        REP(d, 4) {
            REP(s, 1 << D) {
                for (int t = s; t > 0; t = (t - 1) & s) {
                    chmax(dp[d + 1][s], dp[d][s - t] * tmp[t]);
                }
            }
        }
    }
    cout << dp.back().back() << '\n';
}
0