結果
| 問題 |
No.2500 Products in a Range
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-13 22:42:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,495 bytes |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 81,932 KB |
| 実行使用メモリ | 77,568 KB |
| 最終ジャッジ日時 | 2024-09-15 18:28:07 |
| 合計ジャッジ時間 | 22,752 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 46 WA * 15 |
ソースコード
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)