結果

問題 No.3372 Suitable Constraint
コンテスト
ユーザー Meso Meso
提出日時 2025-11-22 10:07:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 32,096 KB
最終ジャッジ日時 2025-11-22 10:07:41
合計ジャッジ時間 3,786 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    
    if 0 in a:
        print(0)
        continue
    
    pos = sorted([x for x in a if x > 0])
    neg = sorted([x for x in a if x < 0])

    if pos and neg:
        print(pos[0] * neg[-1])  
    elif len(neg) > 1:
        print(neg[0] * neg[-1])
    elif len(pos) > 1:
        print(pos[0] * pos[-1])

    
0