結果

問題 No.3372 Suitable Constraint
コンテスト
ユーザー memin
提出日時 2025-11-21 21:37:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,750 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 201,112 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-21 21:37:17
合計ジャッジ時間 4,444 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using pp = pair<int,int>;
#define rep(i, n) for (i = 0; (i) < (n); ++(i))
#define reps(i, a, n) for (i = (a); (i) < (n); ++(i))
#define rrep(i, n) for (i = (n-1); (i) >= (0); --(i))
#define all(a) (a).begin(), (a).end()
#define oor(a,b,h,w) (a<0||a>=h||b<0||b>=w)//out of range
#define fi first
#define se second
#define mkpr(a,b) make_pair(a,b)
#define mktpl(a,b,c) make_tuple(a,b,c)
#define fixp(a) fixed<<setprecision(a) //小数点以下指定
vector<int> dx={1,0,-1,0};//{1,1,0,-1,-1,-1,0,1};
vector<int> dy={0,-1,0,1};//{0,-1,-1,-1,0,1,1,1};
//ll keta_calc(ll x){ll ans=0;while(x){x/=10;ans++;}return ans;}
//ll powll(ll x,ll y){ll ans=1;while(y){ans*=x;y--;}return ans;}
//alias g++='g++ -std=c++17'
#define chmin(a,b) a=min(a,(b))
#define chmax(a,b) a=max(a,(b))

int main(){
    int i=0,j=0;
    int n,m,k;
    int ti,t;
    cin >> t ;
    rep(ti,t){
        cin >> n ;
        vector<ll> a(n);
        bool flag = false;
        ll max_minus=-1001001001001;
        ll min_plus=1001001001001;
        rep(i,n){
            cin >> a[i];
            if(a[i] <= 0){
                flag = true;
                chmax(max_minus , a[i]);
            }else{
                chmin(min_plus , a[i]);
            }
        }
        if(flag){
            cout << max_minus*min_plus << "\n";
            continue;
        }
        sort(all(a));
        cout << a[0]*a[1] << "\n";
    }
    

    //sort(aitem.begin(),aitem.end(),
    //[](const vector<int> &alpha,const vector<int> &beta){return alpha[1] < beta[1];});
    
    // cout << n << endl ;

    //if(flag==0)printf("Yes\n");
    //else printf("No\n");

    return 0;
}
0