結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-13 21:46:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,139 bytes |
| コンパイル時間 | 1,846 ms |
| コンパイル使用メモリ | 169,612 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 17:25:31 |
| 合計ジャッジ時間 | 3,716 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void debug(const char *msg, ...) {
#ifdef CLESIP
va_list arg;
static char pbString[512];
va_start(arg,msg);
vsprintf(pbString,msg,arg);
cerr << "[DEBUG] " << pbString << "\n";
va_end(arg);
#endif
}
using i64 = long long;
using i128 = __int128_t;
template <typename T, typename L> void chkmax(T &x, L y) { if (x < y) x = y; }
template <typename T, typename L> void chkmin(T &x, L y) { if (x > y) x = y; }
const int N = 5010;
int f[N], n;
i64 a[N], l, r;
void solve() {
cin >> n >> l >> r;
for (int i = 1; i <= n; i ++)
cin >> a[i];
sort(a + 1, a + 1 + n);
auto check = [&](i64 val) {
return l <= val && val <= r;
};
int ans = 0;
for (int i = 1; i < n; i ++) {
if (!check(a[i] * a[i + 1]))
continue;
int j = i + 1;
i64 mn = min(a[i], a[i + 1]), mx = max(a[i], a[i + 1]);
while (j + 1 <= n && check(mn * a[j + 1]) && check(mx * a[j + 1])) {
chkmax(mx, a[j + 1]);
chkmin(mn, a[j + 1]);
j ++;
}
chkmax(ans, j - i + 1);
}
cout << ans;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
solve();
return 0;
}