結果

問題 No.2359 A in S ?
ユーザー ニックネーム
提出日時 2023-06-24 01:35:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 804 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 111,508 KB
最終ジャッジ日時 2024-07-01 05:17:12
合計ジャッジ時間 5,917 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,m = map(int,input().split())
xylr = defaultdict(list); z = 10**5; a = [0]*(z+1)
for _ in range(n):
    l,r,x,y = map(int,input().split())
    xylr[(x,y)].append((l,r))
for (x,y),lr in xylr.items():
    d = defaultdict(int); s = 0; i = y
    for l,r in lr: d[l+(y-l)%x] += 1; d[r+1+(y-r-1)%x] -= 1
    while i<=z:
        if i in d: s += d[i]
        a[i] += s; i += x
for v in map(int,input().split()): print(a[v])
0