結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-13 23:17:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 875 bytes |
| コンパイル時間 | 3,579 ms |
| コンパイル使用メモリ | 258,440 KB |
| 最終ジャッジ日時 | 2025-02-17 07:33:12 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 MLE * 8 -- * 35 |
ソースコード
#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;
}
ll op(ll a,ll b){
return max(a,b);
}
ll e(){
return -1;
}
using segtree = atcoder::segtree<ll,op,e>;
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<segtree> dp(n,segtree(n));
rep(chs,n){
dp.at(chs).set(chs,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=dp.at(i).prod(i,up);
if(dp.at(i).get(chs)<g+1) dp.at(i).set(chs,g+1);
}
}
}
ll ans=0;
rep(i,n) rep(j,n){
chmax(ans,dp.at(i).all_prod());
}
cout<<ans<<endl;
}