結果
問題 |
No.1268 Fruit Rush 2
|
ユーザー |
|
提出日時 | 2021-02-20 11:42:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 454 ms / 2,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 188,192 KB |
最終ジャッジ日時 | 2024-09-17 13:22:28 |
合計ジャッジ時間 | 9,868 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
n=int(input()) a=list(map(int,input().split())) a.sort() d={x:1 for x in a} from heapq import heappush,heappop,heapify ary={x:0 for x in a} heapify(a) while a: v=heappop(a) if v in ary: if v in d: d[v]+=ary[v] else: d[v]=ary[v] if v+1 in d: if v+2 in ary: ary[v+2]+=d[v]*d[v+1] else: ary[v+2]=d[v]*d[v+1] heappush(a,v+2) #print(d) #print(ary) ans=sum(ary.values())+n print(ans)