結果

問題 No.33 アメーバがたくさん
ユーザー 👑 colognecologne
提出日時 2022-01-23 16:09:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 71,288 KB
最終ジャッジ日時 2023-08-19 21:21:25
合計ジャッジ時間 2,574 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,132 KB
testcase_01 AC 74 ms
71,288 KB
testcase_02 AC 74 ms
70,944 KB
testcase_03 AC 74 ms
71,044 KB
testcase_04 AC 76 ms
71,076 KB
testcase_05 AC 75 ms
71,240 KB
testcase_06 AC 75 ms
71,176 KB
testcase_07 AC 74 ms
71,008 KB
testcase_08 AC 73 ms
71,156 KB
testcase_09 AC 74 ms
71,072 KB
testcase_10 AC 76 ms
71,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    N, D, T = map(int, input().split())

    mod_dict = {}

    for x in map(int, input().split()):
        if x % D not in mod_dict:
            mod_dict[x % D] = []
        mod_dict[x % D].append(x//D)

    def calc(x):
        events = []
        for i in x:
            events.append((i-T, 1))
            events.append((i+T+1, -1))

        events.sort()
        cur = 0
        ans = 0
        for i in range(len(events)-1):
            tm, val = events[i]
            cur += val
            if cur > 0:
                ans += events[i+1][0] - tm
        return ans

    print(sum(map(calc, mod_dict.values())))


if __name__ == '__main__':
    main()
0