結果

問題 No.2359 A in S ?
ユーザー titia
提出日時 2023-06-23 23:09:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 623 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 162,900 KB
最終ジャッジ日時 2024-07-01 02:56:24
合計ジャッジ時間 11,298 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 TLE * 4 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappop,heappush

N,M=map(int,input().split())
LRXY=[list(map(int,input().split())) for i in range(N)]
A=list(map(int,input().split()))

H=[]

for l,r,x,y in LRXY:
    a=l//x*x+y-x

    while a<l:
        a+=x

    b=r//x*x+y-x

    while b<=r:
        b+=x

    if a<b:
        H.append((a,x,1))
        H.append((b,x,-1))

H.sort()

ANS=[0]*(10**5+1)

while H:
    a,x,ko=heappop(H)

    while H and H[0][0]==a and H[0][1]==x:
        a,x,ko2=heappop(H)
        ko+=ko2

    if ko!=0:
        ANS[a]+=ko
        heappush(H,(a+x,x,ko))

for a in A:
    print(ANS[a])
0