結果

問題 No.1268 Fruit Rush 2
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-20 11:42:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 486 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 1,040 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 187,960 KB
最終ジャッジ日時 2023-10-17 15:42:03
合計ジャッジ時間 12,344 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,476 KB
testcase_01 AC 39 ms
53,476 KB
testcase_02 AC 38 ms
53,476 KB
testcase_03 AC 38 ms
53,476 KB
testcase_04 AC 38 ms
53,476 KB
testcase_05 AC 39 ms
53,476 KB
testcase_06 AC 38 ms
53,476 KB
testcase_07 AC 39 ms
53,476 KB
testcase_08 AC 38 ms
53,476 KB
testcase_09 AC 38 ms
53,476 KB
testcase_10 AC 39 ms
53,476 KB
testcase_11 AC 38 ms
53,476 KB
testcase_12 AC 39 ms
53,476 KB
testcase_13 AC 39 ms
53,476 KB
testcase_14 AC 38 ms
53,476 KB
testcase_15 AC 39 ms
53,476 KB
testcase_16 AC 348 ms
146,792 KB
testcase_17 AC 313 ms
137,792 KB
testcase_18 AC 324 ms
138,400 KB
testcase_19 AC 327 ms
138,180 KB
testcase_20 AC 319 ms
138,396 KB
testcase_21 AC 316 ms
137,832 KB
testcase_22 AC 347 ms
146,580 KB
testcase_23 AC 345 ms
146,316 KB
testcase_24 AC 327 ms
138,444 KB
testcase_25 AC 321 ms
137,844 KB
testcase_26 AC 403 ms
162,668 KB
testcase_27 AC 406 ms
162,348 KB
testcase_28 AC 421 ms
162,364 KB
testcase_29 AC 410 ms
162,352 KB
testcase_30 AC 408 ms
162,348 KB
testcase_31 AC 343 ms
138,448 KB
testcase_32 AC 343 ms
138,448 KB
testcase_33 AC 328 ms
174,724 KB
testcase_34 AC 482 ms
166,736 KB
testcase_35 AC 486 ms
187,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0