結果

問題 No.1268 Fruit Rush 2
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-10-17 07:20:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 201,076 KB
最終ジャッジ日時 2023-09-10 07:52:33
合計ジャッジ時間 9,168 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
72,896 KB
testcase_01 AC 102 ms
72,856 KB
testcase_02 AC 101 ms
73,044 KB
testcase_03 AC 102 ms
72,824 KB
testcase_04 AC 101 ms
72,900 KB
testcase_05 AC 105 ms
73,132 KB
testcase_06 AC 108 ms
72,736 KB
testcase_07 AC 103 ms
72,784 KB
testcase_08 AC 101 ms
72,936 KB
testcase_09 AC 101 ms
72,748 KB
testcase_10 AC 102 ms
72,648 KB
testcase_11 AC 102 ms
72,816 KB
testcase_12 AC 103 ms
72,812 KB
testcase_13 AC 101 ms
72,628 KB
testcase_14 AC 103 ms
72,628 KB
testcase_15 AC 102 ms
72,808 KB
testcase_16 AC 239 ms
126,612 KB
testcase_17 AC 225 ms
120,428 KB
testcase_18 AC 227 ms
121,072 KB
testcase_19 AC 229 ms
120,920 KB
testcase_20 AC 226 ms
120,996 KB
testcase_21 AC 222 ms
120,368 KB
testcase_22 AC 236 ms
126,404 KB
testcase_23 AC 236 ms
126,392 KB
testcase_24 AC 223 ms
121,208 KB
testcase_25 AC 221 ms
120,604 KB
testcase_26 AC 344 ms
200,984 KB
testcase_27 AC 350 ms
200,848 KB
testcase_28 AC 332 ms
200,988 KB
testcase_29 AC 337 ms
201,012 KB
testcase_30 AC 337 ms
201,076 KB
testcase_31 AC 242 ms
141,180 KB
testcase_32 AC 243 ms
141,188 KB
testcase_33 AC 228 ms
172,436 KB
testcase_34 AC 207 ms
140,428 KB
testcase_35 AC 224 ms
172,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

dp = defaultdict(lambda:0)
A.sort()
s = set(A)
for a in A:
    
    if a+1 in s:
        dp[a+1] += 1
    
    dp[a] += dp[a-2]
    
ans = N
for a in A:
    ans += dp[a]
print(ans)
    
    


0