結果

問題 No.2304 Distinct Elements
ユーザー 👑 rin204rin204
提出日時 2024-03-16 15:23:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 238,248 KB
最終ジャッジ日時 2024-03-16 15:23:28
合計ジャッジ時間 13,143 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 254 ms
144,936 KB
testcase_05 AC 209 ms
144,936 KB
testcase_06 AC 208 ms
144,696 KB
testcase_07 AC 206 ms
144,696 KB
testcase_08 AC 231 ms
144,956 KB
testcase_09 AC 319 ms
238,248 KB
testcase_10 AC 315 ms
238,244 KB
testcase_11 AC 347 ms
237,664 KB
testcase_12 AC 322 ms
237,656 KB
testcase_13 AC 327 ms
238,052 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 36 ms
53,460 KB
testcase_20 WA -
testcase_21 AC 37 ms
53,460 KB
testcase_22 WA -
testcase_23 AC 36 ms
53,460 KB
testcase_24 AC 37 ms
53,460 KB
testcase_25 AC 36 ms
53,460 KB
testcase_26 AC 36 ms
53,460 KB
testcase_27 AC 36 ms
53,460 KB
testcase_28 AC 37 ms
53,460 KB
testcase_29 AC 156 ms
127,396 KB
testcase_30 AC 54 ms
69,984 KB
testcase_31 AC 134 ms
109,184 KB
testcase_32 AC 249 ms
180,068 KB
testcase_33 AC 60 ms
74,340 KB
testcase_34 AC 282 ms
180,308 KB
testcase_35 AC 294 ms
200,824 KB
testcase_36 AC 57 ms
72,648 KB
testcase_37 AC 105 ms
100,868 KB
testcase_38 AC 209 ms
141,892 KB
testcase_39 AC 213 ms
142,132 KB
testcase_40 AC 153 ms
114,240 KB
testcase_41 AC 106 ms
100,196 KB
testcase_42 AC 174 ms
132,936 KB
testcase_43 AC 195 ms
167,836 KB
testcase_44 AC 248 ms
166,924 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 37 ms
53,460 KB
testcase_48 AC 37 ms
53,460 KB
testcase_49 AC 201 ms
145,748 KB
testcase_50 AC 201 ms
146,360 KB
testcase_51 AC 198 ms
146,500 KB
testcase_52 WA -
testcase_53 AC 146 ms
107,504 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 167 ms
111,212 KB
testcase_58 AC 178 ms
127,456 KB
testcase_59 AC 169 ms
119,664 KB
testcase_60 AC 35 ms
53,460 KB
testcase_61 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
A.sort()
ans = [0] * n

cnt = {}
tot = 0
for i, a in enumerate(A):
    x = a - i
    cnt[x] = cnt.get(x, 0) + 1
    tot += cnt.get(x + 1, 0)
    cnt[x] += cnt.get(x + 1, 0)
    cnt[x + 1] = 0
    ans[i] += tot

A = [-a for a in A[::-1]]
ans = ans[::-1]

cnt = {}
tot = 0
for i, a in enumerate(A):
    x = a - i
    cnt[x] = cnt.get(x, 0) + 1
    tot += cnt.get(x + 1, 0)
    cnt[x] += cnt.get(x + 1, 0)
    cnt[x + 1] = 0
    ans[i] += tot

print(min(ans))
0