結果

問題 No.3372 Suitable Constraint
コンテスト
ユーザー Meso Meso
提出日時 2025-11-22 10:00:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 32,720 KB
最終ジャッジ日時 2025-11-22 10:00:53
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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 neg == []:
        print(pos[0] * pos[1])
        continue
    
    if pos == []:
        print(neg[-1] * neg[-2])
        continue
    
    cand1 = neg[-1] * pos[0]
    cand2 = neg[0] * pos[-1]
    print(max(cand1, cand2))
0