結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-13 23:24:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,465 ms / 2,000 ms |
| コード長 | 882 bytes |
| コンパイル時間 | 4,109 ms |
| コンパイル使用メモリ | 255,344 KB |
| 最終ジャッジ日時 | 2025-02-17 07:35:07 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 61 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
void chmax(ll &a,ll b){
if(a<b) a=b;
}
int main(){
int n,l,r;
cin>>n>>l>>r;
vector<ll> a(n);
rep(i,n) cin>>a.at(i);
sort(a.begin(),a.end());
auto isok=[&](ll x){
return l<=x&&x<=r;
};
vector<vector<ll>> dp(n,vector<ll>(n,-1));
vector<vector<ll>> vmx(n,vector<ll>(n+1,-1));
rep(chs,n){
dp.at(chs).at(chs)=1;
vmx.at(chs).at(chs+1)=1;
rep(i,chs){
if(isok(a.at(i)*a.at(chs))){
ll up=chs;
ll dw=i;
while(up-dw>1){
ll md=(up+dw)/2;
if(isok(a.at(md)*a.at(chs))) dw=md;
else up=md;
}
ll g=vmx.at(i).at(up);
chmax(dp.at(i).at(chs),g+1);
chmax(vmx.at(i).at(chs+1),max(vmx.at(i).at(chs),g+1));
}
}
}
ll ans=0;
rep(i,n) rep(j,n){
chmax(ans,dp.at(i).at(j));
}
cout<<ans<<endl;
}