結果

問題 No.1268 Fruit Rush 2
ユーザー aaaaaaaaaa2230
提出日時 2020-10-31 18:04:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 138,928 KB
最終ジャッジ日時 2024-07-22 05:07:02
合計ジャッジ時間 5,504 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
a.sort()

dic = {}
for i in range(n):
    dic[a[i]] = i

ans = n
used = [0]*n
for i in range(1,n):
    if used[i]:
        continue
    used[i] = 1
    if a[i] == a[i-1]+1:
        count = 0
        s = 1
        k = a[i]
        while k+count*2 in dic:
            ans += s
            if k+count*2-1 in dic:
                s += 1
            used[dic[k+count*2]] = 1
            count += 1
        

print(ans)
0