結果

問題 No.1268 Fruit Rush 2
ユーザー nebukuro09nebukuro09
提出日時 2020-10-23 23:42:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 205,804 KB
最終ジャッジ日時 2023-09-28 19:02:51
合計ジャッジ時間 7,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,200 KB
testcase_01 AC 75 ms
71,196 KB
testcase_02 AC 75 ms
71,296 KB
testcase_03 AC 76 ms
71,196 KB
testcase_04 AC 78 ms
71,300 KB
testcase_05 AC 76 ms
71,388 KB
testcase_06 AC 79 ms
71,476 KB
testcase_07 AC 76 ms
71,572 KB
testcase_08 AC 76 ms
71,388 KB
testcase_09 AC 77 ms
71,076 KB
testcase_10 AC 76 ms
71,028 KB
testcase_11 AC 77 ms
71,316 KB
testcase_12 AC 76 ms
71,280 KB
testcase_13 AC 75 ms
71,292 KB
testcase_14 AC 75 ms
71,396 KB
testcase_15 AC 75 ms
71,304 KB
testcase_16 AC 191 ms
126,172 KB
testcase_17 AC 178 ms
119,476 KB
testcase_18 AC 181 ms
120,304 KB
testcase_19 AC 180 ms
120,212 KB
testcase_20 AC 174 ms
120,324 KB
testcase_21 AC 177 ms
119,644 KB
testcase_22 AC 192 ms
126,220 KB
testcase_23 AC 190 ms
125,972 KB
testcase_24 AC 180 ms
120,284 KB
testcase_25 AC 177 ms
119,700 KB
testcase_26 AC 244 ms
165,472 KB
testcase_27 AC 239 ms
165,284 KB
testcase_28 AC 239 ms
165,348 KB
testcase_29 AC 240 ms
165,272 KB
testcase_30 AC 243 ms
165,332 KB
testcase_31 AC 216 ms
141,352 KB
testcase_32 AC 209 ms
140,632 KB
testcase_33 AC 196 ms
171,684 KB
testcase_34 AC 196 ms
149,868 KB
testcase_35 AC 216 ms
205,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(sorted(map(int, input().split())))
B = set(A)

dp = {}
ans = 0

for a in A:
    if a in dp:
        dp[a] += 1
    else:
        dp[a] = 1
    if a - 1 in dp:
        if a + 1 in dp:
            dp[a + 1] += dp[a - 1]
        else:
            dp[a + 1] = dp[a - 1]

print(sum(dp.values()))
0