結果

問題 No.2500 Products in a Range
ユーザー mkawa2mkawa2
提出日時 2023-10-13 22:04:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,726 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 80,560 KB
最終ジャッジ日時 2023-10-13 22:04:57
合計ジャッジ時間 9,075 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,412 KB
testcase_01 AC 69 ms
71,272 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 79 ms
76,536 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 78 ms
76,176 KB
testcase_17 AC 82 ms
76,308 KB
testcase_18 AC 78 ms
76,340 KB
testcase_19 AC 78 ms
76,076 KB
testcase_20 AC 80 ms
76,320 KB
testcase_21 AC 76 ms
76,280 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 101 ms
76,352 KB
testcase_29 AC 87 ms
76,396 KB
testcase_30 AC 79 ms
76,200 KB
testcase_31 WA -
testcase_32 AC 72 ms
71,272 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 70 ms
71,384 KB
testcase_36 AC 68 ms
71,204 KB
testcase_37 AC 69 ms
71,092 KB
testcase_38 AC 68 ms
71,300 KB
testcase_39 AC 70 ms
70,860 KB
testcase_40 AC 80 ms
71,232 KB
testcase_41 AC 71 ms
71,400 KB
testcase_42 WA -
testcase_43 AC 71 ms
71,188 KB
testcase_44 AC 73 ms
76,216 KB
testcase_45 AC 70 ms
71,088 KB
testcase_46 AC 74 ms
76,360 KB
testcase_47 RE -
testcase_48 AC 75 ms
75,440 KB
testcase_49 WA -
testcase_50 AC 80 ms
76,372 KB
testcase_51 AC 85 ms
76,192 KB
testcase_52 AC 78 ms
76,436 KB
testcase_53 AC 77 ms
76,328 KB
testcase_54 AC 69 ms
71,272 KB
testcase_55 AC 76 ms
76,328 KB
testcase_56 AC 84 ms
76,168 KB
testcase_57 AC 76 ms
76,088 KB
testcase_58 AC 81 ms
76,312 KB
testcase_59 AC 79 ms
76,540 KB
testcase_60 AC 70 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def f(pos):
    arr = [0]*z+pos
    if not arr: return 0
    n = len(arr)
    i = 0
    while i+1 < n and arr[i]*arr[i+1] < l: i += 1
    j = n-1
    while j-1 >= 0 and arr[j]*arr[j-1] > r: j -= 1
    return max(j-i+1, 1)

n, l, r = LI()
aa = LI()
pos = []
neg = []
z = 0
for a in aa:
    if a < 0:
        neg.append(a)
    elif a > 0:
        pos.append(a)
    else:
        z += 1
pos.sort()
neg.sort(reverse=True)
# pos[2,3,5,6]
# neg[-1,-2,-4,-5,-7]

if r < 0:
    for a in pos:
        for b in neg:
            if l <= a*b <= r:
                print(2)
                exit()
    ans = 1
elif l >= 0 or not neg or not pos:
    ans = max(f(pos), f(neg))
else:
    n, m = len(pos), len(neg)
    j = m-1
    ans = max(f(pos), f(neg))
    for i in range(n-1):
        if i and pos[i-1]*pos[i] > r: break
        while j-1 >= 0 and neg[j]*neg[j-1] > r or j >= 0 and neg[j]*pos[i] < l: j -= 1
        if j < 0: break
        ans = max(i+1+j+1+z)

print(ans)
0