結果

問題 No.2359 A in S ?
ユーザー titiatitia
提出日時 2023-06-24 00:18:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 872 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 79,656 KB
最終ジャッジ日時 2023-09-13 19:28:43
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
78,932 KB
testcase_01 AC 106 ms
78,500 KB
testcase_02 AC 125 ms
79,656 KB
testcase_03 AC 106 ms
78,708 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import deque
from operator import itemgetter

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

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

LIST=[[] for i in range(10**5+1)]

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

    LIST[x].append([a,1])
    LIST[x].append([b,-1])

for x in range(10**5+1):
    if LIST[x]==[]:
        continue

    LIST[x].sort(key=itemgetter(0))

    Q=deque()

    for ind,com in LIST[x]:
        
        while Q and Q[0][0]<ind:
            a,b=Q.popleft()
            if b!=0:
                ANS[a]+=b
                Q.append([a+x,b])

        if Q and ind==Q[0][0]:
            Q[0][1]+=com
        else:
            Q.append([ind,com])

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