結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,356 KB
testcase_05 AC 2 ms
4,356 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 4 ms
4,352 KB
testcase_08 AC 5 ms
4,352 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 13 ms
4,352 KB
testcase_11 AC 16 ms
4,356 KB
testcase_12 AC 7 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 10 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 3 ms
4,352 KB
testcase_17 AC 3 ms
4,352 KB
testcase_18 AC 3 ms
4,352 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 4 ms
4,352 KB
testcase_23 AC 4 ms
4,352 KB
testcase_24 AC 4 ms
4,348 KB
testcase_25 AC 22 ms
4,352 KB
testcase_26 AC 22 ms
4,352 KB
testcase_27 AC 23 ms
4,352 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 6 ms
4,352 KB
testcase_34 AC 14 ms
4,352 KB
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 1 ms
4,352 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 1 ms
4,352 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 1 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,372 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 23 ms
4,348 KB
testcase_48 AC 1 ms
4,356 KB
testcase_49 WA -
testcase_50 AC 3 ms
4,376 KB
testcase_51 AC 3 ms
4,352 KB
testcase_52 AC 3 ms
4,348 KB
testcase_53 AC 3 ms
4,348 KB
testcase_54 AC 1 ms
4,348 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 3 ms
4,348 KB
testcase_58 AC 3 ms
4,348 KB
testcase_59 AC 4 ms
4,352 KB
testcase_60 AC 2 ms
4,356 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));
    if(A.size() > 0 && B.size() > 0){
    	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] = max(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) 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