結果

問題 No.1792 科学の甲子園
コンテスト
ユーザー ygussany
提出日時 2021-12-21 08:09:23
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 4,000 ms
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 205 ms
コンパイル使用メモリ 39,780 KB
最終ジャッジ日時 2026-02-22 08:40:33
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

const int bit[7] = {1, 2, 4, 8, 16, 32, 64};

void chmax(long long* a, long long b)
{
	if (*a < b) *a = b;
}

int main()
{
	int i, j, k, N;
	long long A[6], max[64] = {}, tmp;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 0; j < 6; j++) scanf("%lld", &(A[j]));
		for (k = 0; k < bit[6]; k++) {
			for (j = 0, tmp = 1; j < 6; j++) if ((k & bit[j]) != 0) tmp *= A[j];
			chmax(&(max[k]), tmp);
		}
	}
	
	int l;
	long long ans = 0;
	for (i = 0; i < bit[6]; i++) {
		for (j = i + 1; j < bit[6]; j++) {
			if ((i & j) != 0) continue;
			for (k = j + 1; k < bit[6]; k++) {
				if (((i | j) & k) != 0) continue;
				for (l = k + 1; l < bit[6]; l++) {
					if (((i | j | k) & l) != 0) continue;
					chmax(&ans, max[i] * max[j] * max[k] * max[l]);
				}
			}
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}
0