結果

問題 No.2500 Products in a Range
ユーザー titiatitia
提出日時 2023-10-14 02:37:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,086 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 78,368 KB
最終ジャッジ日時 2023-10-14 02:37:55
合計ジャッジ時間 18,214 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,944 KB
testcase_01 AC 73 ms
71,356 KB
testcase_02 AC 128 ms
77,196 KB
testcase_03 AC 89 ms
76,072 KB
testcase_04 AC 100 ms
77,076 KB
testcase_05 AC 104 ms
76,728 KB
testcase_06 AC 90 ms
76,260 KB
testcase_07 AC 239 ms
78,344 KB
testcase_08 AC 520 ms
78,368 KB
testcase_09 AC 109 ms
76,896 KB
testcase_10 AC 469 ms
77,832 KB
testcase_11 AC 561 ms
77,676 KB
testcase_12 AC 276 ms
77,484 KB
testcase_13 AC 122 ms
77,492 KB
testcase_14 AC 758 ms
78,044 KB
testcase_15 AC 153 ms
77,900 KB
testcase_16 AC 153 ms
77,380 KB
testcase_17 AC 341 ms
78,044 KB
testcase_18 AC 131 ms
77,096 KB
testcase_19 AC 88 ms
76,300 KB
testcase_20 AC 83 ms
76,116 KB
testcase_21 AC 81 ms
76,196 KB
testcase_22 AC 991 ms
77,908 KB
testcase_23 AC 960 ms
77,664 KB
testcase_24 AC 991 ms
77,940 KB
testcase_25 AC 749 ms
77,536 KB
testcase_26 AC 786 ms
77,564 KB
testcase_27 AC 771 ms
78,088 KB
testcase_28 AC 177 ms
76,260 KB
testcase_29 AC 81 ms
76,132 KB
testcase_30 AC 86 ms
76,424 KB
testcase_31 WA -
testcase_32 AC 79 ms
75,628 KB
testcase_33 AC 250 ms
77,564 KB
testcase_34 AC 496 ms
77,632 KB
testcase_35 AC 74 ms
71,268 KB
testcase_36 AC 73 ms
71,296 KB
testcase_37 AC 72 ms
70,936 KB
testcase_38 AC 74 ms
71,380 KB
testcase_39 AC 76 ms
71,352 KB
testcase_40 AC 72 ms
71,264 KB
testcase_41 AC 74 ms
71,120 KB
testcase_42 AC 73 ms
71,248 KB
testcase_43 AC 71 ms
71,132 KB
testcase_44 WA -
testcase_45 AC 77 ms
76,028 KB
testcase_46 AC 75 ms
75,984 KB
testcase_47 AC 753 ms
77,844 KB
testcase_48 AC 89 ms
75,696 KB
testcase_49 WA -
testcase_50 AC 165 ms
77,472 KB
testcase_51 AC 203 ms
78,072 KB
testcase_52 AC 227 ms
77,828 KB
testcase_53 AC 140 ms
77,380 KB
testcase_54 AC 76 ms
76,172 KB
testcase_55 AC 203 ms
77,292 KB
testcase_56 AC 229 ms
77,480 KB
testcase_57 AC 265 ms
77,432 KB
testcase_58 AC 117 ms
76,992 KB
testcase_59 AC 208 ms
77,596 KB
testcase_60 AC 109 ms
77,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if r<0:
    for i in range(n):
        for j in range(i+1,n):
            if l<=A[i]*A[j]<=r:
                print(2)
                exit()
    print(1)
    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(reverse=True)

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:
    ANS=1
    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()

ANS=1
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]

        #print(i,j,LIST)

        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