結果

問題 No.2500 Products in a Range
ユーザー hato336
提出日時 2023-10-13 21:43:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,267 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2024-09-15 17:21:30
合計ジャッジ時間 11,227 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40 WA * 19 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#n = int(input())
#
#alist = []
#s = input()
n,l,r = map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
alist = list(map(int,input().split()))
alist.sort()
ans = 1
temp = 1
for i in range(n-1):
    if l <= alist[i] * alist[i+1] <= r and alist[i] * alist[i+1] > 0:
        temp += 1
    else:
        ans = max(ans,temp)
        temp = 1
ans = max(ans,temp)
#print(alist)
m,p = [],[]
z = 0
for i in alist:
    if i<0:
        m.append(i)
    elif i>0:
        p.append(i)
    else:
        z += 1
m.sort()
p.sort()
for j in range(len(m)):
    i = m[j]
    check = 0
    for k in range(j,len(m)-1):
        if not (l <= m[k] * m[k+1] <= r):
            check = 1
            break
    if check:
        continue
    idx = 0
    while idx != len(p) - 1 and l <= i * p[idx] <= r:
        idx += 1
    if not (l <= i * p[idx] <= r):
        idx -= 1
    check = 0
    for k in range(idx):
        if not(l <= p[k] * p[k+1] <= r):
            check = 1
            break
    if check:continue
    ans = max(ans,len(m)-j+idx+1+ (z if l <= 0 <= r else 0))
    #print(m,p,j,idx,len(m)-j+idx+1)

print(ans)
0