結果

問題 No.3372 Suitable Constraint
コンテスト
ユーザー sai
提出日時 2025-11-21 22:27:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 790 bytes
コンパイル時間 2,848 ms
コンパイル使用メモリ 282,272 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-21 22:27:34
合計ジャッジ時間 5,206 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

void solve() {
  long long ans = 1LL << 60;
  int n;
  std::cin >> n;
  std::vector<int> X, Y;
  for (int i = 0; i < n; i++) {
    int a;
    std::cin >> a;
    if (a > 0) {
      X.push_back(a);
    }
    if (a < 0) {
      Y.push_back(a);
    }
    if (a == 0) {
      ans = 0;
    }
  }
  std::sort(X.begin(), X.end());
  std::sort(Y.begin(), Y.end());
  if ((int)X.size() == 0) {
    std::cout << std::min(ans, 1LL * Y[0] * Y.back()) << '\n';
  } else if ((int)Y.size() == 0) {
    std::cout << std::min(ans, 1LL * X[0] * X.back()) << '\n';
  } else {
    std::cout << std::min(ans, 1LL * X[0] * Y.back()) << '\n';
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int tc;
  std::cin >> tc;
  for (;tc--;) {
    solve();
  }
}
0