結果
問題 | No.2500 Products in a Range |
ユーザー | flygon |
提出日時 | 2023-10-13 22:19:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,708 ms / 2,000 ms |
コード長 | 1,108 bytes |
コンパイル時間 | 420 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-09-15 18:03:44 |
合計ジャッジ時間 | 15,962 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 61 |
ソースコード
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)