結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-13 23:09:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,438 bytes |
| コンパイル時間 | 2,069 ms |
| コンパイル使用メモリ | 199,884 KB |
| 最終ジャッジ日時 | 2025-02-17 07:30:47 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 59 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0); cout.tie(0);
ios::sync_with_stdio(false);
long long N, L, R;
cin >> N >> L >> R;
vector<long long> A(N), C;
for(int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end());
int ans = 1;
for(int i = 0; i < N; i++) {
for(int j = i + 1; j < N; j++) {
if(j - i <= 4) {
bool fn = true;
for(int k = i; k < j; k++) {
for(int l = k + 1; l <= j; l++) {
if(A[k] * A[l] < L || A[k] * A[l] > R) {
fn = false;
}
}
}
if(fn) {
ans = max(ans, j - i + 1);
}
} else {
vector<long long> B = {A[i], A[i + 1], A[j - 1], A[j]};
bool fn = true;
for(int k = 0; k < 4; k++) {
for(int l = k + 1; l < 4; l++) {
if(B[k] * B[l] < L || B[k] * B[l] > R) {
fn = false;
}
}
}
if(fn) {
ans = max(ans, j - i + 1);
}
}
}
}
if(R < 0) {
vector<long long> neg, pos;
for(int i = 0; i < N; i++) {
if(A[i] < 0) {
neg.emplace_back(A[i]);
}
if(A[i] > 0) {
pos.emplace_back(A[i]);
}
}
for(long long x : neg) {
for(long long y : pos) {
if(L <= x * y && x * y <= R) {
ans = max(ans, 2);
}
}
}
}
cout << ans << '\n';
return 0;
}