結果

問題 No.2500 Products in a Range
ユーザー daiotadaiota
提出日時 2023-10-13 22:14:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 1,713 ms
コンパイル使用メモリ 172,564 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 17:57:20
合計ジャッジ時間 3,428 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)



int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j,k;

	ll n,l,r;
	cin >> n >> l >> r;

	vector<ll> a(n);
	for(i=0;i<n;i++) cin >> a[i];

	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	ll mx=1;
	for(i=0;i<n-1;i++){
		ll L=2e18,R=-2e18;
		for(j=i+1;j<n;j++){
			R=max({R,a[i]*a[i+1],a[j]*a[j-1]});
			L=min({L,a[i]*a[j],a[j]*a[j-1]});

			if(r>=R && l<=L){
				mx=max(mx,j-i+1);
			}else{
				break;
			}
		}
	}

	cout << mx << endl;


	return 0;
}
0