結果

問題 No.2359 A in S ?
ユーザー ntudantuda
提出日時 2023-06-27 22:11:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 634 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 123,188 KB
最終ジャッジ日時 2023-09-17 20:32:38
合計ジャッジ時間 7,548 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,348 KB
testcase_01 AC 87 ms
71,640 KB
testcase_02 AC 108 ms
78,696 KB
testcase_03 AC 89 ms
72,092 KB
testcase_04 AC 310 ms
103,704 KB
testcase_05 AC 331 ms
121,648 KB
testcase_06 AC 279 ms
103,824 KB
testcase_07 AC 261 ms
102,368 KB
testcase_08 AC 634 ms
123,188 KB
testcase_09 AC 262 ms
106,240 KB
testcase_10 AC 317 ms
121,248 KB
testcase_11 AC 325 ms
123,144 KB
testcase_12 AC 276 ms
103,800 KB
testcase_13 AC 276 ms
103,668 KB
testcase_14 AC 269 ms
103,896 KB
testcase_15 AC 255 ms
104,224 KB
testcase_16 AC 269 ms
103,580 KB
testcase_17 AC 270 ms
103,620 KB
testcase_18 AC 262 ms
103,796 KB
testcase_19 AC 271 ms
103,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
LRXY = [list(map(int, input().split())) for _ in range(N)]
A = list(map(int, input().split()))
maxa = max(A)
from collections import defaultdict
dic = defaultdict(list)

for i, (l, r, x, y) in enumerate(LRXY):
    if maxa < r:
        LRXY[i][1] = maxa
        r = maxa
    dic[(x, y)].append((l, r))
    maxa = max(maxa, y)
ans = [0] * (maxa + 1)
for k, v in dic.items():
    x, y = k
    n = maxa // x + 2
    imost = [0] * (n + 1)
    for l, r in v:
        L = - ((y - l) // x)
        R = (r - y) // x
        imost[L] += 1
        imost[R + 1] -= 1
    for i in range(n - 1):
        tmp = imost[i]
        imost[i + 1] += tmp
        if i * x + y <= maxa:
            ans[i * x + y] += tmp
for a in A:
    print(ans[a])
0