結果

問題 No.1792 科学の甲子園
ユーザー rlangevinrlangevin
提出日時 2023-04-27 02:04:29
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 3,084 ms / 4,000 ms
コード長 1,841 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 121,416 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-23 05:51:54
合計ジャッジ時間 93,674 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,014 ms
6,676 KB
testcase_01 AC 3,013 ms
6,676 KB
testcase_02 AC 3,014 ms
6,676 KB
testcase_03 AC 3,013 ms
6,676 KB
testcase_04 AC 3,014 ms
6,676 KB
testcase_05 AC 3,038 ms
6,676 KB
testcase_06 AC 3,013 ms
6,676 KB
testcase_07 AC 3,012 ms
6,676 KB
testcase_08 AC 3,019 ms
6,676 KB
testcase_09 AC 3,015 ms
6,676 KB
testcase_10 AC 3,015 ms
6,676 KB
testcase_11 AC 3,037 ms
6,676 KB
testcase_12 AC 3,013 ms
6,676 KB
testcase_13 AC 3,037 ms
6,676 KB
testcase_14 AC 3,084 ms
6,676 KB
testcase_15 AC 3,021 ms
6,676 KB
testcase_16 AC 3,011 ms
6,676 KB
testcase_17 AC 3,013 ms
6,676 KB
testcase_18 AC 3,019 ms
6,676 KB
testcase_19 AC 3,024 ms
6,676 KB
testcase_20 AC 3,018 ms
6,676 KB
testcase_21 AC 3,024 ms
6,676 KB
testcase_22 AC 3,043 ms
6,676 KB
testcase_23 AC 3,022 ms
6,676 KB
testcase_24 AC 3,011 ms
6,676 KB
testcase_25 AC 3,013 ms
6,676 KB
testcase_26 AC 3,012 ms
6,676 KB
testcase_27 AC 3,021 ms
6,676 KB
testcase_28 AC 3,078 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    srand(314);
    vector<vector<long long>> L(N, vector<long long>(6));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 6; j++) {
            cin >> L[i][j];
        }
    }

    auto f = [&](double tt, long long val) {
        vector<long long> A(64);
        vector<long long> B(64);
        for (int s = 0; s < (1 << 6); s++) {
            for (int i = 0; i < N/2; i++) {
                for (int j = i + 1; j < N/2; j++) {
                    long long v = 1;
                    for (int k = 0; k < 6; k++) {
                        if ((s >> k) & 1) {
                            v *= max(L[i][k], L[j][k]);
                        }
                    }
                    A[s] = max(A[s], v);
                }
            }
        }

        for (int s = 0; s < (1 << 6); s++) {
            for (int i = N/2; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    long long v = 1;
                    for (int k = 0; k < 6; k++) {
                        if ((s >> k) & 1) {
                            v *= max(L[i][k], L[j][k]);
                        }
                    }
                    B[s] = max(B[s], v);
                }
            }
        }

        long long ans = 0;
        for (int i = 0; i < (1 << 6); i++) {
            ans = max(ans, A[i] * B[63 - i]);
        }
        return ans;
    };

    long long ans = 0;
    double sTime = clock() / CLOCKS_PER_SEC;
    while (clock() / CLOCKS_PER_SEC - sTime < 3.0) {
        random_shuffle(L.begin(), L.end());
        ans = max(ans, f(sTime, ans));
    }
    cout << ans << endl;

    return 0;
}
0