結果

問題 No.2500 Products in a Range
ユーザー titiatitia
提出日時 2023-10-14 02:36:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,081 bytes
コンパイル時間 1,061 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 78,464 KB
最終ジャッジ日時 2023-10-14 02:36:53
合計ジャッジ時間 19,193 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,424 KB
testcase_01 AC 73 ms
71,156 KB
testcase_02 AC 128 ms
76,948 KB
testcase_03 AC 91 ms
76,184 KB
testcase_04 AC 99 ms
77,100 KB
testcase_05 AC 104 ms
76,848 KB
testcase_06 AC 94 ms
76,408 KB
testcase_07 WA -
testcase_08 AC 493 ms
78,060 KB
testcase_09 WA -
testcase_10 AC 470 ms
77,816 KB
testcase_11 AC 564 ms
77,616 KB
testcase_12 AC 278 ms
77,576 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 151 ms
77,648 KB
testcase_17 AC 354 ms
77,676 KB
testcase_18 AC 128 ms
77,592 KB
testcase_19 AC 88 ms
76,128 KB
testcase_20 AC 82 ms
76,332 KB
testcase_21 AC 80 ms
76,396 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 755 ms
77,652 KB
testcase_26 AC 791 ms
77,704 KB
testcase_27 WA -
testcase_28 AC 175 ms
76,424 KB
testcase_29 AC 83 ms
76,144 KB
testcase_30 AC 87 ms
76,388 KB
testcase_31 WA -
testcase_32 AC 78 ms
75,588 KB
testcase_33 AC 253 ms
77,556 KB
testcase_34 AC 509 ms
77,552 KB
testcase_35 AC 72 ms
71,368 KB
testcase_36 AC 72 ms
71,416 KB
testcase_37 AC 75 ms
71,136 KB
testcase_38 AC 75 ms
70,984 KB
testcase_39 AC 77 ms
71,176 KB
testcase_40 AC 73 ms
70,968 KB
testcase_41 AC 75 ms
71,432 KB
testcase_42 AC 73 ms
71,264 KB
testcase_43 AC 74 ms
71,140 KB
testcase_44 WA -
testcase_45 AC 84 ms
76,056 KB
testcase_46 AC 76 ms
75,948 KB
testcase_47 AC 756 ms
77,708 KB
testcase_48 AC 80 ms
75,700 KB
testcase_49 WA -
testcase_50 AC 168 ms
77,680 KB
testcase_51 AC 208 ms
78,076 KB
testcase_52 AC 234 ms
77,552 KB
testcase_53 AC 142 ms
77,496 KB
testcase_54 AC 78 ms
76,060 KB
testcase_55 AC 181 ms
77,416 KB
testcase_56 AC 239 ms
77,480 KB
testcase_57 AC 268 ms
77,436 KB
testcase_58 AC 117 ms
77,176 KB
testcase_59 AC 208 ms
77,604 KB
testcase_60 AC 107 ms
77,116 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)

        
        
        
            
    
0