結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-01 21:09:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 2,000 ms |
| コード長 | 901 bytes |
| コンパイル時間 | 1,133 ms |
| コンパイル使用メモリ | 81,384 KB |
| 最終ジャッジ日時 | 2025-02-16 16:03:00 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 61 |
ソースコード
#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());
std::vector<int> p(n, n), q(n, -1), p2(n), q2(n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (l <= a[i] * a[j] and a[i] * a[j] <= r) {
p[i] = std::min(p[i], j);
q[i] = std::max(q[i], j);
}
}
p2[i] = std::max(p[i], i + 1);
q2[i] = std::min(q[i], i - 1);
}
int ans = 1;
for (int i = 0; i < n; ++i) {
for (int j = p2[i]; j <= q[i]; ++j) {
ans = std::max(ans, 2 + std::max(0, q2[j] - p2[i] + 1));
}
}
std::cout << ans << std::endl;
}