結果

問題 No.1268 Fruit Rush 2
ユーザー tyawanmusityawanmusi
提出日時 2020-10-23 22:44:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 766 ms / 2,000 ms
コード長 232 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 10,532 KB
実行使用メモリ 90,840 KB
最終ジャッジ日時 2023-09-28 17:02:31
合計ジャッジ時間 12,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,632 KB
testcase_01 AC 19 ms
8,536 KB
testcase_02 AC 19 ms
8,624 KB
testcase_03 AC 19 ms
8,532 KB
testcase_04 AC 19 ms
8,480 KB
testcase_05 AC 19 ms
8,472 KB
testcase_06 AC 19 ms
8,536 KB
testcase_07 AC 19 ms
8,608 KB
testcase_08 AC 19 ms
8,476 KB
testcase_09 AC 19 ms
8,532 KB
testcase_10 AC 19 ms
8,604 KB
testcase_11 AC 19 ms
8,608 KB
testcase_12 AC 18 ms
8,612 KB
testcase_13 AC 19 ms
8,624 KB
testcase_14 AC 19 ms
8,532 KB
testcase_15 AC 18 ms
8,604 KB
testcase_16 AC 369 ms
48,764 KB
testcase_17 AC 338 ms
47,520 KB
testcase_18 AC 341 ms
47,824 KB
testcase_19 AC 358 ms
46,268 KB
testcase_20 AC 351 ms
47,544 KB
testcase_21 AC 344 ms
47,704 KB
testcase_22 AC 379 ms
48,028 KB
testcase_23 AC 380 ms
47,988 KB
testcase_24 AC 344 ms
48,072 KB
testcase_25 AC 336 ms
47,940 KB
testcase_26 AC 755 ms
90,360 KB
testcase_27 AC 749 ms
90,064 KB
testcase_28 AC 748 ms
90,168 KB
testcase_29 AC 766 ms
90,840 KB
testcase_30 AC 745 ms
90,004 KB
testcase_31 AC 474 ms
54,852 KB
testcase_32 AC 469 ms
54,848 KB
testcase_33 AC 411 ms
64,012 KB
testcase_34 AC 419 ms
69,616 KB
testcase_35 AC 451 ms
79,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
from collections import defaultdict
d1=defaultdict(int)
d2=defaultdict(int)
for i in a:
  d1[i]+=1
  d2[i+1]+=d1[i]*d2[i-1]+d1[i]*d1[i-1]
  ans+=d2[i+1]+d1[i]
print(ans)
0