結果
問題 |
No.2500 Products in a Range
|
ユーザー |
|
提出日時 | 2023-09-02 03:29:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 972 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 78,820 KB |
最終ジャッジ日時 | 2025-02-16 17:54:59 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 WA * 9 |
ソースコード
// WA (嘘: 連続部分列のみを考えてよい (反例: 一部の答えが2のケース)) #include <algorithm> #include <iostream> #include <vector> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; long long l, r; std::cin >> n >> l >> r; std::vector<long long> a(n); for (auto &e : a) std::cin >> e; std::sort(a.begin(), a.end()); int ans = 1; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { const long long x = a[i] * a[i + 1]; const long long y = a[j - 1] * a[j]; const long long z = a[i] * a[j]; const long long min_prod = std::min({ x, y, z }); const long long max_prod = std::max({ x, y, z }); if (l <= min_prod and max_prod <= r) { ans = std::max(ans, j - i + 1); } else { break; } } } std::cout << ans << std::endl; }