結果
問題 |
No.2500 Products in a Range
|
ユーザー |
![]() |
提出日時 | 2023-09-02 19:14:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,155 bytes |
コンパイル時間 | 1,273 ms |
コンパイル使用メモリ | 105,972 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-06-12 06:12:11 |
合計ジャッジ時間 | 6,152 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 50 |
ソースコード
#include <algorithm> #include <cassert> #include <cstdint> #include <iostream> #include <iterator> #include <vector> // <TLE> // O(n^3) 時間 int main() { constexpr int kMaxN = 5000, kMinA = -1000000000, kMaxA = 1000000000; int n, l, r; std::cin >> n >> l >> r; assert(1 <= n && n <= kMaxN && kMinA <= l && l <= r && r <= kMaxA); std::vector<std::int64_t> a(n); for (int i = 0; i < n; ++i) { std::cin >> a[i]; assert(kMinA <= a[i] && a[i] <= kMaxA); } std::ranges::sort(a); int ans = 1; for (int i = 0; i < n; ++i) { int j = i + 1; for (; j < n; ++j) { if (!std::all_of(std::next(a.begin(), i), std::next(a.begin(), j), [l, r, &a, j](const std::int64_t x) -> bool { return l <= x * a[j] && x * a[j] <= r; })) { break; } } ans = std::max(ans, j - i); } if (ans == 1) { for (int i = 0; ans == 1 && i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (l <= a[i] * a[j] && a[i] * a[j] <= r) { ans = 2; break; } } } } std::cout << ans << '\n'; return 0; }