結果

問題 No.1268 Fruit Rush 2
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2020-10-31 18:18:53
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 140,640 KB
最終ジャッジ日時 2023-09-29 10:32:26
合計ジャッジ時間 6,906 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,496 KB
testcase_01 AC 64 ms
71,492 KB
testcase_02 AC 64 ms
71,084 KB
testcase_03 AC 67 ms
71,116 KB
testcase_04 AC 64 ms
71,256 KB
testcase_05 AC 63 ms
71,220 KB
testcase_06 AC 64 ms
71,356 KB
testcase_07 AC 66 ms
71,324 KB
testcase_08 AC 66 ms
71,320 KB
testcase_09 AC 66 ms
71,340 KB
testcase_10 AC 68 ms
71,352 KB
testcase_11 AC 67 ms
71,408 KB
testcase_12 AC 67 ms
71,348 KB
testcase_13 AC 65 ms
71,236 KB
testcase_14 AC 65 ms
71,124 KB
testcase_15 AC 66 ms
71,176 KB
testcase_16 AC 161 ms
121,908 KB
testcase_17 AC 155 ms
121,932 KB
testcase_18 AC 159 ms
122,236 KB
testcase_19 AC 164 ms
122,300 KB
testcase_20 AC 164 ms
122,780 KB
testcase_21 AC 156 ms
121,800 KB
testcase_22 AC 160 ms
119,436 KB
testcase_23 AC 159 ms
121,156 KB
testcase_24 AC 158 ms
122,208 KB
testcase_25 AC 158 ms
121,776 KB
testcase_26 AC 196 ms
134,284 KB
testcase_27 AC 193 ms
134,068 KB
testcase_28 AC 194 ms
134,176 KB
testcase_29 AC 191 ms
134,300 KB
testcase_30 AC 194 ms
134,352 KB
testcase_31 AC 176 ms
112,128 KB
testcase_32 AC 178 ms
112,040 KB
testcase_33 AC 158 ms
140,640 KB
testcase_34 AC 137 ms
112,024 KB
testcase_35 AC 155 ms
140,440 KB
権限があれば一括ダウンロードができます

ソースコード

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