結果
問題 |
No.1268 Fruit Rush 2
|
ユーザー |
![]() |
提出日時 | 2020-10-23 23:16:48 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 750 bytes |
コンパイル時間 | 633 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 151,048 KB |
最終ジャッジ日時 | 2024-07-21 13:08:59 |
合計ジャッジ時間 | 5,821 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 RE * 7 |
ソースコード
import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) even = [] odd = [] for a in A: if a % 2 == 0: even.append(a) else: odd.append(a) even.sort() odd.sort() cnt_even = {even[-1] : 1} cnt = 1 for i in range(len(even) - 1)[::-1]: if even[i+1] == even[i] + 2: cnt += 1 else: cnt = 1 cnt_even[even[i]] = cnt cnt_odd = {odd[-1] : 1} cnt = 1 for i in range(len(odd) - 1)[::-1]: if odd[i+1] == odd[i] + 2: cnt += 1 else: cnt = 1 cnt_odd[odd[i]] = cnt ans = N for a in A: if a % 2 == 0: if a + 1 in cnt_odd: ans += cnt_odd[a + 1] else: if a + 1 in cnt_even: ans += cnt_even[a + 1] print(ans)