結果

問題 No.1268 Fruit Rush 2
ユーザー Navier_Boltzmann
提出日時 2022-10-17 07:09:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 194,600 KB
最終ジャッジ日時 2024-06-27 23:16:21
合計ジャッジ時間 7,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 17
権限があれば一括ダウンロードができます

ソースコード

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)


for a in A:
    
    dp[a+1] += 1
    
    dp[a] += dp[a-2]
    
ans = N
for a in A:
    ans += dp[a]
print(ans)
    
    


0