結果

問題 No.2500 Products in a Range
ユーザー titiatitia
提出日時 2023-10-14 02:41:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,016 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 78,364 KB
最終ジャッジ日時 2023-10-14 02:42:12
合計ジャッジ時間 20,348 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,280 KB
testcase_01 AC 73 ms
71,092 KB
testcase_02 AC 130 ms
77,404 KB
testcase_03 AC 95 ms
76,436 KB
testcase_04 AC 106 ms
76,884 KB
testcase_05 AC 111 ms
76,964 KB
testcase_06 AC 99 ms
76,192 KB
testcase_07 AC 249 ms
78,060 KB
testcase_08 AC 603 ms
78,140 KB
testcase_09 AC 117 ms
77,024 KB
testcase_10 AC 515 ms
78,056 KB
testcase_11 AC 594 ms
77,856 KB
testcase_12 AC 322 ms
77,824 KB
testcase_13 AC 134 ms
77,368 KB
testcase_14 AC 866 ms
78,136 KB
testcase_15 AC 189 ms
77,756 KB
testcase_16 AC 254 ms
77,332 KB
testcase_17 AC 376 ms
77,724 KB
testcase_18 AC 178 ms
77,300 KB
testcase_19 AC 184 ms
76,284 KB
testcase_20 AC 208 ms
76,288 KB
testcase_21 AC 88 ms
76,520 KB
testcase_22 AC 1,115 ms
78,364 KB
testcase_23 AC 1,130 ms
77,864 KB
testcase_24 AC 1,098 ms
77,820 KB
testcase_25 AC 825 ms
77,820 KB
testcase_26 AC 848 ms
77,824 KB
testcase_27 AC 863 ms
78,072 KB
testcase_28 AC 174 ms
76,496 KB
testcase_29 AC 99 ms
76,304 KB
testcase_30 AC 94 ms
76,300 KB
testcase_31 AC 96 ms
76,280 KB
testcase_32 AC 85 ms
76,144 KB
testcase_33 AC 268 ms
77,784 KB
testcase_34 AC 543 ms
77,524 KB
testcase_35 AC 74 ms
71,124 KB
testcase_36 AC 73 ms
71,028 KB
testcase_37 AC 74 ms
71,020 KB
testcase_38 AC 73 ms
71,028 KB
testcase_39 AC 75 ms
71,332 KB
testcase_40 AC 74 ms
71,060 KB
testcase_41 AC 73 ms
71,260 KB
testcase_42 AC 72 ms
71,132 KB
testcase_43 AC 76 ms
71,364 KB
testcase_44 WA -
testcase_45 AC 79 ms
76,012 KB
testcase_46 AC 93 ms
76,364 KB
testcase_47 AC 854 ms
77,812 KB
testcase_48 AC 77 ms
75,560 KB
testcase_49 AC 87 ms
76,376 KB
testcase_50 AC 196 ms
77,076 KB
testcase_51 AC 242 ms
77,680 KB
testcase_52 AC 333 ms
77,632 KB
testcase_53 AC 159 ms
77,472 KB
testcase_54 AC 80 ms
76,152 KB
testcase_55 AC 196 ms
77,368 KB
testcase_56 AC 216 ms
77,324 KB
testcase_57 AC 446 ms
77,236 KB
testcase_58 AC 132 ms
77,308 KB
testcase_59 AC 325 ms
77,352 KB
testcase_60 AC 111 ms
76,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,l,r=map(int,input().split())
A=list(map(int,input().split()))

ANS=1
for i in range(n):
    for j in range(i+1,n):
        if l<=A[i]*A[j]<=r:
            ANS=2

if r<0:
    print(ANS)
    exit()

PLUS=[]
MINUS=[]
zero=0

for a in A:
    if a>0:
        PLUS.append(a)
    elif a<0:
        MINUS.append(a)
    else:
        zero+=1
    
PLUS.sort()
MINUS.sort()

def check(x,y,A):
    for i in range(x+1,x+3):
        if x<=i<=y:
            if x!=i:
                if l<=A[x]*A[i]<=r:
                    pass
                else:
                    return False
            if y!=i:
                if l<=A[y]*A[i]<=r:
                    pass
                else:
                    return False

    for i in range(y-2,y):
        if x<=i<=y:
            if x!=i:
                if l<=A[x]*A[i]<=r:
                    pass
                else:
                    return False
            if y!=i:
                if l<=A[y]*A[i]<=r:
                    pass
                else:
                    return False

    return True

if l>0:
    for i in range(len(PLUS)):
        for j in range(i,len(PLUS)):
            if check(i,j,PLUS)==True:
                ANS=max(ANS,j-i+1)

    for i in range(len(MINUS)):
        for j in range(i,len(MINUS)):
            if check(i,j,MINUS)==True:
                ANS=max(ANS,j-i+1)

    print(ANS)
    exit()

MINUS.reverse()

for i in range(len(PLUS)+1):
    for j in range(len(MINUS)+1):
        x0=0
        if i-2>=0:
            x0=PLUS[i-2]
        x1=0
        if i-1>=0:
            x1=PLUS[i-1]

        y0=0
        if j-2>=0:
            y0=MINUS[j-2]
        y1=0
        if j-1>=0:
            y1=MINUS[j-1]

        LIST=[x0,x1,y0,y1]

        flag=1

        for k in range(4):
            for m in range(k+1,4):
                if l<=LIST[k]*LIST[m]<=r:
                    pass
                else:
                    flag=0

        if flag==1:
            ANS=max(ANS,i+j)

print(ANS+zero)

        
        
        
            
    
0