結果

問題 No.2500 Products in a Range
ユーザー flygonflygon
提出日時 2023-10-13 22:19:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,764 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 79,204 KB
最終ジャッジ日時 2023-10-13 22:19:58
合計ジャッジ時間 19,291 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,572 KB
testcase_01 AC 101 ms
71,320 KB
testcase_02 AC 145 ms
77,880 KB
testcase_03 AC 131 ms
77,304 KB
testcase_04 AC 153 ms
78,076 KB
testcase_05 AC 136 ms
77,988 KB
testcase_06 AC 121 ms
77,304 KB
testcase_07 AC 295 ms
78,096 KB
testcase_08 AC 1,636 ms
78,516 KB
testcase_09 AC 151 ms
78,108 KB
testcase_10 AC 244 ms
77,284 KB
testcase_11 AC 279 ms
77,664 KB
testcase_12 AC 178 ms
77,748 KB
testcase_13 AC 184 ms
78,260 KB
testcase_14 AC 1,764 ms
78,272 KB
testcase_15 AC 199 ms
78,180 KB
testcase_16 AC 304 ms
77,868 KB
testcase_17 AC 203 ms
77,564 KB
testcase_18 AC 217 ms
77,748 KB
testcase_19 AC 429 ms
78,260 KB
testcase_20 AC 483 ms
78,140 KB
testcase_21 AC 151 ms
78,440 KB
testcase_22 AC 583 ms
78,408 KB
testcase_23 AC 452 ms
78,288 KB
testcase_24 AC 546 ms
78,652 KB
testcase_25 AC 369 ms
77,688 KB
testcase_26 AC 365 ms
77,660 KB
testcase_27 AC 362 ms
77,828 KB
testcase_28 AC 401 ms
78,204 KB
testcase_29 AC 162 ms
78,200 KB
testcase_30 AC 158 ms
78,332 KB
testcase_31 AC 134 ms
78,156 KB
testcase_32 AC 135 ms
78,120 KB
testcase_33 AC 166 ms
77,472 KB
testcase_34 AC 251 ms
77,572 KB
testcase_35 AC 100 ms
71,332 KB
testcase_36 AC 97 ms
71,584 KB
testcase_37 AC 97 ms
71,332 KB
testcase_38 AC 95 ms
71,540 KB
testcase_39 AC 96 ms
71,268 KB
testcase_40 AC 95 ms
71,264 KB
testcase_41 AC 97 ms
71,392 KB
testcase_42 AC 95 ms
71,448 KB
testcase_43 AC 96 ms
71,388 KB
testcase_44 AC 133 ms
77,644 KB
testcase_45 AC 117 ms
77,544 KB
testcase_46 AC 165 ms
77,952 KB
testcase_47 AC 358 ms
77,496 KB
testcase_48 AC 124 ms
77,348 KB
testcase_49 AC 127 ms
77,544 KB
testcase_50 AC 223 ms
78,464 KB
testcase_51 AC 292 ms
78,972 KB
testcase_52 AC 435 ms
78,132 KB
testcase_53 AC 201 ms
79,204 KB
testcase_54 AC 114 ms
77,528 KB
testcase_55 AC 227 ms
78,332 KB
testcase_56 AC 252 ms
78,152 KB
testcase_57 AC 540 ms
78,176 KB
testcase_58 AC 158 ms
78,196 KB
testcase_59 AC 460 ms
78,032 KB
testcase_60 AC 141 ms
77,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

def ju(m):
    ret = 0
    for s in range(n):
        goal = s+m-1
        if goal >= n:break
        ok = 1
        for i in range(s, goal+1):
            if i == s:
                ok &= l <= a[i] * a[i+1] <= r
                ok &= l <= a[i] * a[goal] <= r
            elif i == goal:
                ok &= l <= a[s] * a[i] <= r
                ok &= l <= a[i-1] * a[i] <= r
            else:
                ok &= l <= a[s] * a[i] <= r
                ok &= l <= a[i] * a[goal] <= r
        ret |= ok
    return ret
    

n,l,r = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
le = 2
ri = n+1
for _ in range(15):
    m = (le+ri)//2
    if ju(m):
        le = m
    else:
        ri = m

if le != 2:
    print(le)
else:
    ok = 0
    for i in range(n):
        for j in range(i+1, n):
            ok |= l <= a[i]*a[j] <= r
    print(2) if ok else print(1)


0