結果
| 問題 |
No.3372 Suitable Constraint
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-21 22:16:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 626 bytes |
| コンパイル時間 | 1,360 ms |
| コンパイル使用メモリ | 168,336 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-21 22:16:55 |
| 合計ジャッジ時間 | 2,833 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 14 |
ソースコード
#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[1] << endl;
}
else if(a[0]<0 && a[n-1]<=0){
cout << a[n-2]*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;
}