結果

問題 No.33 アメーバがたくさん
ユーザー convexineqconvexineq
提出日時 2020-11-25 07:06:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 428 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 71,540 KB
最終ジャッジ日時 2023-10-01 01:40:03
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,160 KB
testcase_01 AC 71 ms
71,340 KB
testcase_02 AC 73 ms
71,296 KB
testcase_03 AC 73 ms
71,148 KB
testcase_04 AC 70 ms
71,376 KB
testcase_05 AC 71 ms
71,436 KB
testcase_06 AC 71 ms
71,184 KB
testcase_07 AC 71 ms
71,360 KB
testcase_08 AC 71 ms
71,540 KB
testcase_09 AC 72 ms
71,272 KB
testcase_10 AC 71 ms
71,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,d,t = map(int,input().split())
*x, = map(int,input().split())
dic = {}
for xi in x:
    pi,qi = xi//d,xi%d
    if qi in dic:
        dic[qi].append(pi)
    else:
        dic[qi] = [pi]

ans = 0
for lst in dic.values():
    lst.sort()
    st = []
    for i in lst:
        if st and st[-1][1] >= i-t:
            st[-1][1] = i+t
        else:
            st.append([i-t,i+t])
    for L,R in st:
        ans += R-L+1

print(ans)
0