結果
| 問題 |
No.1792 科学の甲子園
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-12-21 00:16:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 4,000 ms |
| コード長 | 1,680 bytes |
| コンパイル時間 | 3,330 ms |
| コンパイル使用メモリ | 180,732 KB |
| 最終ジャッジ日時 | 2025-01-27 04:20:48 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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;
}
chocorusk