結果

問題 No.2500 Products in a Range
ユーザー rlangevinrlangevin
提出日時 2023-10-13 22:06:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,367 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 82,760 KB
最終ジャッジ日時 2023-10-13 22:06:49
合計ジャッジ時間 28,728 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,212 KB
testcase_01 AC 71 ms
71,396 KB
testcase_02 AC 152 ms
77,908 KB
testcase_03 AC 114 ms
77,272 KB
testcase_04 AC 130 ms
77,504 KB
testcase_05 AC 152 ms
77,944 KB
testcase_06 AC 101 ms
76,688 KB
testcase_07 AC 320 ms
79,356 KB
testcase_08 AC 1,020 ms
82,760 KB
testcase_09 AC 204 ms
78,920 KB
testcase_10 AC 766 ms
82,040 KB
testcase_11 AC 919 ms
81,868 KB
testcase_12 AC 434 ms
81,052 KB
testcase_13 AC 158 ms
77,768 KB
testcase_14 AC 1,026 ms
81,364 KB
testcase_15 AC 195 ms
78,148 KB
testcase_16 AC 702 ms
80,416 KB
testcase_17 AC 403 ms
80,036 KB
testcase_18 AC 412 ms
80,176 KB
testcase_19 AC 823 ms
81,636 KB
testcase_20 AC 927 ms
81,052 KB
testcase_21 AC 204 ms
79,484 KB
testcase_22 AC 1,061 ms
82,456 KB
testcase_23 AC 766 ms
81,244 KB
testcase_24 AC 1,041 ms
81,668 KB
testcase_25 AC 1,367 ms
81,792 KB
testcase_26 AC 1,364 ms
81,844 KB
testcase_27 AC 1,306 ms
81,708 KB
testcase_28 AC 767 ms
80,552 KB
testcase_29 AC 251 ms
79,848 KB
testcase_30 AC 220 ms
78,536 KB
testcase_31 AC 135 ms
78,044 KB
testcase_32 AC 124 ms
77,496 KB
testcase_33 AC 394 ms
80,848 KB
testcase_34 AC 761 ms
81,656 KB
testcase_35 AC 68 ms
71,060 KB
testcase_36 AC 67 ms
71,124 KB
testcase_37 AC 81 ms
71,244 KB
testcase_38 AC 69 ms
71,204 KB
testcase_39 AC 70 ms
71,052 KB
testcase_40 AC 70 ms
71,424 KB
testcase_41 AC 71 ms
71,268 KB
testcase_42 AC 69 ms
71,300 KB
testcase_43 AC 70 ms
71,368 KB
testcase_44 AC 74 ms
76,132 KB
testcase_45 AC 69 ms
71,204 KB
testcase_46 AC 74 ms
76,116 KB
testcase_47 AC 1,295 ms
81,784 KB
testcase_48 AC 96 ms
77,012 KB
testcase_49 AC 106 ms
77,212 KB
testcase_50 AC 493 ms
81,408 KB
testcase_51 AC 526 ms
81,460 KB
testcase_52 AC 847 ms
81,836 KB
testcase_53 AC 272 ms
80,524 KB
testcase_54 AC 86 ms
76,380 KB
testcase_55 AC 446 ms
79,128 KB
testcase_56 AC 448 ms
80,348 KB
testcase_57 AC 807 ms
80,572 KB
testcase_58 AC 220 ms
78,484 KB
testcase_59 AC 875 ms
81,096 KB
testcase_60 AC 178 ms
78,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

N, l, r = map(int, input().split())
B = sorted(list(map(int, input().split())))
A = []
zero = 0
for b in B:
    if b == 0:
        zero += 1
        N -= 1
    else:
        A.append(b)
        
def f(a):
    if a > 0:
        return (l + a - 1)//a, r//a
    else:
        return (-r -a - 1)//(-a), (-l)//(-a)

if A == []:
    ans = 0
else:
    ans = 1
D = dict()
for a in A:
    mi, ma = f(a)
    D[a] = bisect_right(A, a)
    D[mi] = bisect_right(A, mi)
    D[ma] = bisect_right(A, ma)
    D[a-1] = bisect_right(A, a-1)
    D[mi-1] = bisect_right(A, mi-1)
    D[ma-1] = bisect_right(A, ma-1)


for i in range(N):
    for j in range(i + 1, N):
        mi1, ma1 = f(A[i])
        mi2, ma2 = f(A[j])
        mi = max(mi1, mi2, A[i]) - 1
        ma = min(ma1, ma2, A[j])
        cnt = int(A[i] <= mi) + int(A[j] > ma)
        if not (l <= A[i] * A[j] <= r):
            continue
        ans = max(ans, max(0, D[ma] - D[mi]) + cnt)
        
if l <= 0 <= r:
    ans += zero
print(max(1, ans))
0