結果

問題 No.1268 Fruit Rush 2
ユーザー aaaaaaaaaa2230
提出日時 2020-10-31 18:20:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 504 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 45,372 KB
最終ジャッジ日時 2024-07-22 05:07:39
合計ジャッジ時間 9,576 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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 = 1
        s = 1
        k = a[i]
        ans += 1
        while k+count*2 in dic:
            ans += s
            if k+count*2-1 in dic:
                s += 1
                ans += 1
            used[dic[k+count*2]] = 1
            count += 1
print(ans)
0