結果

問題 No.2359 A in S ?
ユーザー meruuu61779999meruuu61779999
提出日時 2023-06-24 07:31:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,356 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 263,756 KB
最終ジャッジ日時 2023-09-14 02:57:12
合計ジャッジ時間 11,502 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 419 ms
259,224 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 621 ms
261,304 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 517 ms
263,756 KB
testcase_10 AC 550 ms
261,020 KB
testcase_11 RE -
testcase_12 AC 588 ms
261,476 KB
testcase_13 AC 535 ms
261,800 KB
testcase_14 WA -
testcase_15 AC 560 ms
260,700 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 615 ms
260,612 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import math


# xで割ったあまりがyになる自然数の中で、n以上で最小のものを返す関数
def f(n, x, y):
    mo = n % x
    if mo <= y:
        return n + y - mo
    else:
        return n + x + y - mo


# xで割ったあまりがyになる自然数の中で、n以下で最小のものを返す関数
def g(n, x, y):
    mo = n % x
    if y <= mo:
        return n + y - mo
    else:
        return n + x + y - mo


N, M = map(int, input().split())
sq = math.isqrt(10 ** 5)
higher = []
lower = [[] for _ in range(sq)]
for _ in range(N):
    l, r, x, y = map(int, input().split())
    if x < sq:
        lower[x].append((y, l, r))
    else:
        higher.append((l, r, x, y))

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

for l, r, x, y in higher:
    start = f(l, x, y)
    end = g(r, x, y)
    for i in range(start, end + 1, x):
        line[i] += 1

for x, gr in enumerate(lower):
    x_line = [0] * (10 ** 5 + 1)
    for y, l, r in gr:
        start = f(l, x, y)
        end = g(r, x, y) + x
        x_line[start] += 1
        try:
            x_line[end] -= 1
        except IndexError:
            pass
    for i in range(x, 10 ** 5 + 1):
        x_line[i] += x_line[i - x]

    for i in range(10 ** 5 + 1):
        line[i] += x_line[i]

A = list(map(int, input().split()))
for a in A:
    print(line[a])
0