結果

問題 No.2500 Products in a Range
ユーザー miya145592
提出日時 2023-10-13 23:40:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 883 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 324,224 KB
最終ジャッジ日時 2024-09-15 19:32:34
合計ジャッジ時間 5,516 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 TLE * 1 -- * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import sys
input = sys.stdin.readline
N, L, R = map(int, input().split())
A = list(map(int, input().split()))
Z = [[0, i, set()] for i in range(N)]
for i in range(N):
    for j in range(N):
        if i==j or L<=A[i]*A[j]<=R:
            pass
        else:
            Z[i][0]-=1
            Z[i][2].add(j)
heapq.heapify(Z)
ng = 0
S = dict()
while Z[0][0]<0:
    c, r, COL = heapq.heappop(Z)
    if r in S:
        for col in S[r]:
            COL.discard(col)
        if c+len(S[r])>Z[0][0]:
            heapq.heappush(Z, [c+len(S[r]), r, COL])
            del S[r]
            continue
        del S[r]
    if len(COL)>0:
        for col in COL:
            if col not in S:
                S[col] = [r]
            else:
                S[col].append(r)
            #idx = D[col]
            #Z[idx][0]+=1
            #Z[idx][2].discard(r)
        ng += 1
print(N-ng)
0