結果

問題 No.2029 Swap Min Max Min
ユーザー ShirotsumeShirotsume
提出日時 2022-08-05 22:20:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 108,920 KB
最終ジャッジ日時 2023-10-14 00:12:39
合計ジャッジ時間 7,395 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,380 KB
testcase_01 AC 71 ms
71,396 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 99 ms
87,908 KB
testcase_06 AC 123 ms
105,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 90 ms
81,012 KB
testcase_11 WA -
testcase_12 AC 104 ms
92,368 KB
testcase_13 WA -
testcase_14 AC 137 ms
107,316 KB
testcase_15 WA -
testcase_16 AC 134 ms
107,392 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 135 ms
107,404 KB
testcase_20 AC 138 ms
107,228 KB
testcase_21 AC 139 ms
107,220 KB
testcase_22 AC 136 ms
107,104 KB
testcase_23 AC 135 ms
107,308 KB
testcase_24 AC 137 ms
107,340 KB
testcase_25 AC 132 ms
107,388 KB
testcase_26 AC 131 ms
107,384 KB
testcase_27 AC 71 ms
71,252 KB
testcase_28 AC 72 ms
71,352 KB
testcase_29 AC 73 ms
71,372 KB
testcase_30 AC 74 ms
71,088 KB
testcase_31 AC 76 ms
71,348 KB
testcase_32 AC 73 ms
71,232 KB
testcase_33 AC 71 ms
71,528 KB
testcase_34 WA -
testcase_35 AC 74 ms
71,528 KB
testcase_36 AC 74 ms
71,380 KB
testcase_37 AC 73 ms
71,380 KB
testcase_38 AC 131 ms
108,848 KB
testcase_39 AC 129 ms
107,224 KB
testcase_40 AC 127 ms
108,920 KB
testcase_41 AC 129 ms
103,744 KB
testcase_42 AC 130 ms
103,800 KB
testcase_43 AC 129 ms
106,988 KB
testcase_44 AC 133 ms
107,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n = ii()

a = li()

x = n // 2

for i in range(n):
    if a[i] <= x:
        a[i] = 0
    else:
        a[i] = 1

zero = []
even = []

for i in range(n):
    if a[i] == 0:
        zero.append(i) 
for i in range(1, n, 2):
    even.append(i)
ans = 0
for i in range(n // 2):
    ans += abs(zero[i] - even[i])
if n % 2 == 0:
    now = ans
    for i in range(n // 2):
        now -= abs(zero[i] - even[i])
        even[i] -= 1
        now += abs(zero[i] - even[i])
        ans = min(ans, now)
print(x, ans)
        
0