結果
| 問題 | No.3372 Suitable Constraint |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-11 02:37:32 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 342 ms / 2,000 ms |
| コード長 | 707 bytes |
| 記録 | |
| コンパイル時間 | 3,264 ms |
| コンパイル使用メモリ | 20,688 KB |
| 実行使用メモリ | 36,056 KB |
| 最終ジャッジ日時 | 2026-02-11 02:37:43 |
| 合計ジャッジ時間 | 10,660 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
N = int(input())
A = list(map(int, input().split()))
has_zero = False
has_pos = False
has_neg = False
minA = 10**30
maxA = -10**30
min_pos = 10**30
max_neg = -10**30
for x in A:
if x == 0:
has_zero = True
if x > 0:
has_pos = True
min_pos = min(min_pos, x)
if x < 0:
has_neg = True
max_neg = max(max_neg, x)
minA = min(minA, x)
maxA = max(maxA, x)
if has_zero:
print(0)
elif not has_pos or not has_neg:
print(minA * maxA)
else:
print(min_pos * max_neg)