結果

問題 No.1268 Fruit Rush 2
コンテスト
ユーザー rlangevin
提出日時 2023-02-07 23:37:25
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 168 ms / 2,000 ms
+ 971µs
コード長 551 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 99 ms
コンパイル使用メモリ 64,384 KB
実行使用メモリ 115,232 KB
最終ジャッジ日時 2026-10-20 08:20:13
合計ジャッジ時間 6,542 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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