結果

問題 No.3372 Suitable Constraint
コンテスト
ユーザー daiota
提出日時 2025-11-21 22:37:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 168,404 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-21 22:37:46
合計ジャッジ時間 3,110 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)











int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;





	int T;
	cin >> T;
	while(T--){


		ll n;
		cin >> n;

		vector<ll> a(n);
		REP(i,n) cin >> a[i];


		sort(a.begin(),a.end());

		if(a[0]>=0){
			cout << a[0]*a[n-1] << endl;
		}
		else if(a[0]<0 && a[n-1]<=0){
			cout << a[0]*a[n-1] << endl;
		}
		else if(a[0]<0 && a[n-1]>0){
			REP(i,n){
				if(a[i]>0){
					cout << a[i-1]*a[i] << endl;
					break;
				}
			}
		}




	}







	return 0;

}
0