結果

問題 No.1792 科学の甲子園
ユーザー chocoruskchocorusk
提出日時 2021-12-21 00:16:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 4,000 ms
コード長 1,680 bytes
コンパイル時間 2,966 ms
コンパイル使用メモリ 188,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 01:29:00
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 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 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 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 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;

int main()
{
    int n;cin>>n;
    ll a[6][10010];
    for(int i=0; i<n; i++) for(int j=0; j<6; j++) cin>>a[j][i];
    ll x[1<<6]={};
    for(int i=0; i<(1<<6); i++){
        int p=popcount(i);
        if(p>=4) continue;
        for(int j=0; j<n; j++){
            ll q=1;
            for(int k=0; k<6; k++){
                if(i&(1<<k)) q*=a[k][j];
            }
            x[i]=max(x[i], q);
        }
    }
    ll ans=0;
    for(int i=0; i<(1<<6); i++){
        int p=popcount(i);
        if(p==3){
            ll q=x[i];
            for(int j=0; j<6; j++){
                if(!(i&(1<<j))) q*=x[1<<j];
            }
            ans=max(ans, q);
        }else if(p==2){
            for(int j=0; j<(1<<6); j++){
                if(!(i&j) && popcount(j)==2){
                    ll q=x[i]*x[j];
                    for(int k=0; k<6; k++){
                        if(!(i&(1<<k)) && !(j&(1<<k))) q*=x[1<<k];
                    }
                    ans=max(ans, q);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
0