提出 #70455787


ソースコード 拡げる

n, m, c = map(int, input().split())
a = list(map(int, input().split()))

d = dict()
for a_i in a:
    if a_i not in d:
        d[a_i] = 0
    d[a_i] += 1

sort_a = sorted(d.items(), key=lambda x:x[0])
lst = list()
keys = list()
last = sort_a[-1][0]
for key, val in sort_a:
    diff = (key - last) % m
    lst.append(val)
    keys.append((key, diff))
    last = key

accu = [0]
for l_i in lst + lst:
    accu.append(accu[-1] + l_i)

l = c // n
k = c % n

if len(keys) == 1:
    count = l * n + (n if k > 0 else 0)
    print(count * m)
else:
    ans = 0
    right = 0
    for i, (key, diff) in enumerate(keys):
        while accu[right] - accu[i] < k:
            right += 1
        ans += (l * n + accu[right] - accu[i]) * diff

    print(ans)

提出情報

提出日時
問題 D - On AtCoder Conference
ユーザ hyouri
言語 Python (PyPy 3.10-v7.3.12)
得点 425
コード長 781 Byte
結果 AC
実行時間 793 ms
メモリ 315824 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 2
AC × 32
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 59 ms 76600 KiB
example_01.txt AC 58 ms 76316 KiB
hand_00.txt AC 147 ms 181328 KiB
hand_01.txt AC 146 ms 181036 KiB
hand_02.txt AC 793 ms 313516 KiB
hand_03.txt AC 121 ms 139152 KiB
hand_04.txt AC 58 ms 76628 KiB
hand_05.txt AC 59 ms 76480 KiB
random_00.txt AC 127 ms 138728 KiB
random_01.txt AC 127 ms 139088 KiB
random_02.txt AC 131 ms 138840 KiB
random_03.txt AC 167 ms 154284 KiB
random_04.txt AC 192 ms 168924 KiB
random_05.txt AC 175 ms 160960 KiB
random_06.txt AC 473 ms 227580 KiB
random_07.txt AC 474 ms 227816 KiB
random_08.txt AC 446 ms 216624 KiB
random_09.txt AC 150 ms 178124 KiB
random_10.txt AC 148 ms 180868 KiB
random_11.txt AC 155 ms 178000 KiB
random_12.txt AC 148 ms 176748 KiB
random_13.txt AC 156 ms 180388 KiB
random_14.txt AC 148 ms 180684 KiB
random_15.txt AC 153 ms 181200 KiB
random_16.txt AC 162 ms 180960 KiB
random_17.txt AC 166 ms 180844 KiB
random_18.txt AC 180 ms 183316 KiB
random_19.txt AC 198 ms 185576 KiB
random_20.txt AC 190 ms 184984 KiB
random_21.txt AC 422 ms 229740 KiB
random_22.txt AC 425 ms 215560 KiB
random_23.txt AC 736 ms 315824 KiB