結果
問題 | No.2500 Products in a Range |
ユーザー |
|
提出日時 | 2023-10-14 16:19:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 888 bytes |
コンパイル時間 | 2,914 ms |
コンパイル使用メモリ | 251,576 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-16 10:42:19 |
合計ジャッジ時間 | 4,863 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 61 |
ソースコード
#include "bits/stdc++.h"#define int long longusing namespace std;signed main() {ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);int n, l, r;cin >> n >> l >> r;vector<int> A(n);for (int i = 0; i < n; i++) {cin >> A[i];}sort(A.begin(), A.end());int ct = 1;for (int i = 0; i + 1 < n; i++) {int mn = A[i], mx = A[i];for (int j = i + 1; j < n; j++) {if (!(l <= 1LL * mn * A[j] && 1LL * mn * A[j] <= r)) {break;}if (!(l <= 1LL * mx * A[j] && 1LL * mx * A[j] <= r)) {break;}ct = max(ct, j - i + 1);mn = min(A[j] * 1LL, mn);mx = max(A[j] * 1LL, mx);}}for (int i = 0; i < n; i++) {for (int j = i + 1; j < n; j++) {if (l <= 1LL * A[i] * A[j] && 1LL * A[i] * A[j] <= r) {ct = max(ct, 2LL);}}}cout << ct << endl;}