結果

問題 No.1268 Fruit Rush 2
ユーザー rlangevinrlangevin
提出日時 2023-02-07 23:37:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 189,724 KB
最終ジャッジ日時 2023-09-19 04:36:09
合計ジャッジ時間 10,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,448 KB
testcase_01 AC 97 ms
71,808 KB
testcase_02 AC 98 ms
71,452 KB
testcase_03 AC 100 ms
71,592 KB
testcase_04 AC 98 ms
71,576 KB
testcase_05 AC 98 ms
71,456 KB
testcase_06 AC 96 ms
71,772 KB
testcase_07 AC 97 ms
71,776 KB
testcase_08 AC 98 ms
71,740 KB
testcase_09 AC 97 ms
71,448 KB
testcase_10 AC 97 ms
71,768 KB
testcase_11 AC 100 ms
71,452 KB
testcase_12 AC 99 ms
71,644 KB
testcase_13 AC 98 ms
71,752 KB
testcase_14 AC 99 ms
71,688 KB
testcase_15 AC 96 ms
71,612 KB
testcase_16 AC 233 ms
136,764 KB
testcase_17 AC 213 ms
129,520 KB
testcase_18 AC 217 ms
130,396 KB
testcase_19 AC 216 ms
130,436 KB
testcase_20 AC 225 ms
129,840 KB
testcase_21 AC 217 ms
129,600 KB
testcase_22 AC 230 ms
124,672 KB
testcase_23 AC 225 ms
136,912 KB
testcase_24 AC 218 ms
130,148 KB
testcase_25 AC 212 ms
129,780 KB
testcase_26 AC 295 ms
152,428 KB
testcase_27 AC 298 ms
152,388 KB
testcase_28 AC 307 ms
152,196 KB
testcase_29 AC 306 ms
152,444 KB
testcase_30 AC 310 ms
151,432 KB
testcase_31 AC 247 ms
144,660 KB
testcase_32 AC 250 ms
142,200 KB
testcase_33 AC 216 ms
153,964 KB
testcase_34 AC 228 ms
187,892 KB
testcase_35 AC 250 ms
189,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
E, O = [], []
for a in A:
    if a % 2:
        O.append(a)
    else:
        E.append(a)
O.sort(reverse=True)
E.sort(reverse=True)
D = defaultdict(int)
now = 1
pre = -1
for od in O:
    if od == pre - 2:
        now += 1
    else:
        now = 1
    D[od - 1] += now
    pre = od
    
now = 1
pre = -1
for ev in E:
    if ev == pre - 2:
        now += 1
    else:
        now = 1
    D[ev - 1] += now
    pre = ev
    
ans = N
for a in A:
    ans += D[a]
print(ans)    
0