結果

問題 No.2500 Products in a Range
ユーザー shotoyooshotoyoo
提出日時 2023-10-13 22:42:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,495 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 79,016 KB
最終ジャッジ日時 2023-10-13 22:43:21
合計ジャッジ時間 21,840 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
72,128 KB
testcase_01 AC 86 ms
72,236 KB
testcase_02 AC 141 ms
78,224 KB
testcase_03 AC 97 ms
77,752 KB
testcase_04 AC 107 ms
78,336 KB
testcase_05 AC 110 ms
78,164 KB
testcase_06 AC 96 ms
77,736 KB
testcase_07 WA -
testcase_08 AC 592 ms
78,440 KB
testcase_09 AC 111 ms
78,176 KB
testcase_10 AC 619 ms
78,808 KB
testcase_11 WA -
testcase_12 AC 344 ms
78,568 KB
testcase_13 AC 119 ms
78,196 KB
testcase_14 AC 779 ms
78,732 KB
testcase_15 AC 140 ms
78,296 KB
testcase_16 AC 431 ms
78,496 KB
testcase_17 AC 259 ms
78,664 KB
testcase_18 AC 271 ms
78,672 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 680 ms
79,016 KB
testcase_23 AC 702 ms
78,764 KB
testcase_24 AC 661 ms
78,632 KB
testcase_25 AC 1,024 ms
78,996 KB
testcase_26 AC 1,059 ms
78,884 KB
testcase_27 AC 1,099 ms
78,756 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 81 ms
72,284 KB
testcase_36 AC 84 ms
72,292 KB
testcase_37 AC 85 ms
72,292 KB
testcase_38 AC 81 ms
71,892 KB
testcase_39 AC 89 ms
72,424 KB
testcase_40 AC 93 ms
72,036 KB
testcase_41 AC 86 ms
72,356 KB
testcase_42 WA -
testcase_43 AC 83 ms
71,872 KB
testcase_44 AC 126 ms
78,340 KB
testcase_45 AC 91 ms
76,828 KB
testcase_46 AC 101 ms
78,128 KB
testcase_47 WA -
testcase_48 AC 96 ms
77,800 KB
testcase_49 WA -
testcase_50 AC 312 ms
78,676 KB
testcase_51 AC 327 ms
78,676 KB
testcase_52 AC 553 ms
78,360 KB
testcase_53 AC 184 ms
78,480 KB
testcase_54 AC 85 ms
76,044 KB
testcase_55 AC 154 ms
78,200 KB
testcase_56 AC 179 ms
78,280 KB
testcase_57 AC 197 ms
77,968 KB
testcase_58 AC 178 ms
78,352 KB
testcase_59 AC 639 ms
78,828 KB
testcase_60 AC 121 ms
77,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()]
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

n,l,r = list(map(int, input().split()))
a = LI()
a.sort()
ps = [v for v in a if v>=0]
ns = [v for v in a if v<0]
ns = ns[::-1]
ans = 1
for i in range(len(ps)):
    for j in range(len(ns)):
        if i+j<=1:
            continue
        MM = []
        if i>=2:
            MM.append(ps[i-1]*ps[i-2])
            MM.append(ps[0]*ps[1])
        if j>=2:
            MM.append(ns[j-1]*ns[j-2])
            MM.append(ns[0]*ns[1])
        if i>=1 and j>=1:
            MM.append(ps[i-1]*ns[j-1])
        if l<=min(MM)<=r and l<=max(MM)<=r:
            ans = max(ans, i+j)
def sub(ps):
    ans = 1
    for i in range(len(ps)):
        for j in range(i+1, len(ps)+1):
            if j-i<=1:
                continue
            if l<=ps[i]*ps[i+1]<=r and l<=ps[j-2]*ps[j-1]<=r:
                ans = max(ans, j-i)
    return ans
ans = max(ans, sub(ps), sub(ns))
print(ans)
0