結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-04 22:36:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 897 bytes |
| コンパイル時間 | 2,020 ms |
| コンパイル使用メモリ | 194,856 KB |
| 最終ジャッジ日時 | 2025-02-17 19:18:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 61 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())
const int N=5005;
int n,l,r,mn[N],mx[N];
ll a[N];
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> n >> l >> r;
for(int i=0; i<n; ++i) cin >> a[i];
sort(a,a+n);
for(int i=0; i<n; ++i){
mx[i]=-1;
for(int j=i-1; j>=0; --j) if(a[i]*a[j]>=l&&a[i]*a[j]<=r){
mx[i]=j;
break;
}
mn[i]=n;
for(int j=i+1; j<n; ++j) if(a[i]*a[j]>=l&&a[i]*a[j]<=r){
mn[i]=j;
break;
}
}
int res=1;
for(int i=0; i<n; ++i) for(int j=i+1; j<n; ++j) if(a[i]*a[j]>=l&&a[i]*a[j]<=r){
int l=mn[i],r=mx[j];
if(l>r) res=max(res,2);
else res=max(res,2+(r-l+1));
}
cout << res << "\n";
}