結果

問題 No.2500 Products in a Range
ユーザー keisuke6keisuke6
提出日時 2023-10-13 22:30:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,293 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 208,056 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 22:30:10
合計ジャッジ時間 4,533 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,352 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 6 ms
4,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
4,356 KB
testcase_17 AC 3 ms
4,352 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 2 ms
4,352 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 1 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 WA -
testcase_43 AC 1 ms
4,348 KB
testcase_44 AC 2 ms
4,352 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 2 ms
4,348 KB
testcase_49 WA -
testcase_50 AC 3 ms
4,352 KB
testcase_51 AC 3 ms
4,352 KB
testcase_52 AC 4 ms
4,352 KB
testcase_53 AC 2 ms
4,352 KB
testcase_54 AC 1 ms
4,348 KB
testcase_55 AC 3 ms
4,352 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 3 ms
4,352 KB
testcase_58 AC 2 ms
4,352 KB
testcase_59 AC 4 ms
4,352 KB
testcase_60 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
signed main(){
    int N,L,R;
    cin>>N>>L>>R;
    int ans = 0;
    vector<int> A = {}, B = {};
    int ad = 0;
    for(int i=0;i<N;i++){
    	int a;
    	cin>>a;
    	if(a == 0) ad++;
    	else if(a < 0) A.push_back(-a);
    	else B.push_back(a);
    }
    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    while(A.size() > 1 && A[A.size()-1]*A[A.size()-2] < L) A.pop_back();
    while(B.size() > 1 && B[B.size()-1]*B[B.size()-2] < L) B.pop_back();
    reverse(A.begin(),A.end());
    reverse(B.begin(),B.end());
    while(A.size() > 1 && A[A.size()-1]*A[A.size()-2] > R) A.pop_back();
    while(B.size() > 1 && B[B.size()-1]*B[B.size()-2] > R) B.pop_back();
    int n = A.size(), m = B.size();
    vector<int> LL(n,1e18), RR(n,-(1e18));
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)if(L <= A[i]*B[j] && A[i]*B[j] <= R){
    	LL[i] = min(LL[i],j);
    	RR[i] = min(RR[i],j);
    }
    for(int i=0;i<n;i++)for(int j=i;j<n;j++){
    	int a = max(LL[i],LL[j]), b = min(RR[i],RR[j]);
    	if(a > b || LL[i] == 1e18 || LL[j] == 1e18 || RR[i] == -1e18 || RR[j] == -1e18) continue;
    	ans = max(ans,j-i+1+b-a+1);
    }
    cout<<max({ans,(int)(A.size()),(int)(B.size())})+(L<=0&&0<=R)*ad<<endl;
}
0