結果

問題 No.1268 Fruit Rush 2
ユーザー hanyuhanyu
提出日時 2020-09-20 00:19:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 862 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 35,456 KB
最終ジャッジ日時 2023-09-06 03:42:04
合計ジャッジ時間 9,528 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,176 KB
testcase_01 AC 17 ms
8,228 KB
testcase_02 AC 17 ms
8,172 KB
testcase_03 AC 16 ms
8,308 KB
testcase_04 AC 16 ms
8,308 KB
testcase_05 AC 15 ms
8,388 KB
testcase_06 AC 15 ms
8,148 KB
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 15 ms
8,184 KB
testcase_10 AC 15 ms
8,192 KB
testcase_11 AC 15 ms
8,188 KB
testcase_12 RE -
testcase_13 AC 15 ms
8,216 KB
testcase_14 AC 14 ms
7,948 KB
testcase_15 RE -
testcase_16 AC 316 ms
25,916 KB
testcase_17 AC 271 ms
23,212 KB
testcase_18 AC 290 ms
24,032 KB
testcase_19 AC 269 ms
23,960 KB
testcase_20 AC 274 ms
23,848 KB
testcase_21 AC 266 ms
23,308 KB
testcase_22 AC 329 ms
26,036 KB
testcase_23 AC 330 ms
25,732 KB
testcase_24 AC 273 ms
23,864 KB
testcase_25 AC 266 ms
23,760 KB
testcase_26 AC 431 ms
29,940 KB
testcase_27 AC 417 ms
29,988 KB
testcase_28 AC 436 ms
30,064 KB
testcase_29 AC 444 ms
30,604 KB
testcase_30 AC 437 ms
30,172 KB
testcase_31 AC 454 ms
29,976 KB
testcase_32 AC 457 ms
30,044 KB
testcase_33 RE -
testcase_34 AC 316 ms
30,068 KB
testcase_35 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

odd = []
even = []
for i in range(n):
    if a[i] % 2 == 1:
        odd.append(a[i])
    else:
        even.append(a[i])

odd = sorted(odd)
even = sorted(even)
odd.append(1e18 - 1)
even.append(1e18)

oddacc = [1] * len(odd)
for i in range(1, len(odd)):
    j = len(odd) - i - 1
    if odd[j] + 2 == odd[j + 1]:
        oddacc[j] += oddacc[j + 1]

evenacc = [1] * len(even)
for i in range(1, len(even)):
    j = len(even) - i - 1
    if even[j] + 2 == even[j + 1]:
        evenacc[j] += evenacc[j + 1]
    
ans = n
it = 0
for i in range(len(odd) - 1):
    while odd[i] >= even[it]:
        it += 1
    if odd[i] + 1 == even[it]:
        ans += evenacc[it]

it = 0
for i in range(len(even) - 1):
    while even[i] >= odd[it]:
        it += 1
    if even[i] + 1 == odd[it]:
        ans += oddacc[it]

print(ans)
0