結果
問題 | No.2359 A in S ? |
ユーザー |
![]() |
提出日時 | 2023-06-24 00:27:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,481 ms / 2,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 81,908 KB |
実行使用メモリ | 208,552 KB |
最終ジャッジ日時 | 2024-07-01 04:12:35 |
合計ジャッジ時間 | 8,567 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import sysinput = sys.stdin.readlinefrom collections import dequefrom operator import itemgetterN,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-xwhile a<l:a+=xb=r//x*x+y-xwhile b<=r:b+=xif a<b:LIST[x].append([a,1])LIST[x].append([b,-1])for x in range(10**5+1):if LIST[x]==[]:continueLIST[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]+=bQ.append([a+x,b])if Q and ind==Q[0][0]:Q[0][1]+=comelse:Q.appendleft([ind,com])for a in A:print(ANS[a])