結果

問題 No.2500 Products in a Range
ユーザー cho435cho435
提出日時 2023-10-13 23:24:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,549 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 4,564 ms
コンパイル使用メモリ 266,272 KB
実行使用メモリ 394,080 KB
最終ジャッジ日時 2023-10-13 23:25:23
合計ジャッジ時間 22,183 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 8 ms
6,780 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 3 ms
4,640 KB
testcase_05 AC 5 ms
5,312 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 136 ms
60,596 KB
testcase_08 AC 484 ms
329,712 KB
testcase_09 AC 4 ms
5,728 KB
testcase_10 AC 742 ms
203,940 KB
testcase_11 AC 1,010 ms
264,644 KB
testcase_12 AC 253 ms
95,804 KB
testcase_13 AC 9 ms
7,760 KB
testcase_14 AC 674 ms
327,460 KB
testcase_15 AC 23 ms
17,084 KB
testcase_16 AC 246 ms
253,308 KB
testcase_17 AC 110 ms
114,144 KB
testcase_18 AC 119 ms
126,820 KB
testcase_19 AC 302 ms
324,432 KB
testcase_20 AC 366 ms
364,980 KB
testcase_21 AC 19 ms
20,940 KB
testcase_22 AC 414 ms
393,968 KB
testcase_23 AC 378 ms
394,024 KB
testcase_24 AC 385 ms
394,072 KB
testcase_25 AC 1,544 ms
393,972 KB
testcase_26 AC 1,501 ms
393,992 KB
testcase_27 AC 1,542 ms
394,080 KB
testcase_28 AC 283 ms
298,132 KB
testcase_29 AC 50 ms
53,992 KB
testcase_30 AC 38 ms
39,528 KB
testcase_31 AC 5 ms
5,920 KB
testcase_32 AC 9 ms
10,108 KB
testcase_33 AC 216 ms
84,040 KB
testcase_34 AC 789 ms
225,812 KB
testcase_35 AC 1 ms
4,352 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 1 ms
4,348 KB
testcase_40 AC 1 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 1 ms
4,348 KB
testcase_43 AC 1 ms
4,348 KB
testcase_44 AC 93 ms
41,264 KB
testcase_45 AC 4 ms
6,312 KB
testcase_46 AC 100 ms
104,200 KB
testcase_47 AC 1,549 ms
393,968 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,352 KB
testcase_50 AC 118 ms
124,952 KB
testcase_51 AC 145 ms
149,044 KB
testcase_52 AC 317 ms
312,696 KB
testcase_53 AC 36 ms
37,728 KB
testcase_54 AC 1 ms
4,352 KB
testcase_55 AC 123 ms
125,012 KB
testcase_56 AC 149 ms
148,972 KB
testcase_57 AC 303 ms
312,812 KB
testcase_58 AC 38 ms
41,108 KB
testcase_59 AC 328 ms
344,924 KB
testcase_60 AC 12 ms
14,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0