結果

問題 No.2029 Swap Min Max Min
ユーザー asumo0729asumo0729
提出日時 2022-08-05 21:53:23
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 675 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 110,288 KB
最終ジャッジ日時 2023-10-14 00:09:03
合計ジャッジ時間 7,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,360 KB
testcase_01 AC 73 ms
71,064 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 95 ms
86,544 KB
testcase_06 AC 110 ms
101,064 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 86 ms
80,672 KB
testcase_11 WA -
testcase_12 AC 99 ms
90,888 KB
testcase_13 WA -
testcase_14 AC 126 ms
108,036 KB
testcase_15 WA -
testcase_16 AC 127 ms
107,820 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 124 ms
107,744 KB
testcase_20 AC 125 ms
107,968 KB
testcase_21 AC 124 ms
107,876 KB
testcase_22 AC 125 ms
107,716 KB
testcase_23 AC 124 ms
108,928 KB
testcase_24 AC 123 ms
108,824 KB
testcase_25 AC 125 ms
108,032 KB
testcase_26 AC 126 ms
108,124 KB
testcase_27 AC 72 ms
70,868 KB
testcase_28 AC 71 ms
71,336 KB
testcase_29 AC 72 ms
71,208 KB
testcase_30 AC 72 ms
71,424 KB
testcase_31 AC 72 ms
71,300 KB
testcase_32 WA -
testcase_33 AC 71 ms
71,276 KB
testcase_34 AC 72 ms
71,224 KB
testcase_35 AC 74 ms
71,288 KB
testcase_36 AC 72 ms
71,212 KB
testcase_37 AC 72 ms
71,068 KB
testcase_38 AC 123 ms
110,144 KB
testcase_39 AC 122 ms
107,892 KB
testcase_40 AC 120 ms
109,168 KB
testcase_41 AC 123 ms
105,160 KB
testcase_42 AC 122 ms
105,432 KB
testcase_43 AC 118 ms
107,452 KB
testcase_44 AC 127 ms
108,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
if  N & 1:
    NN = N // 2
    idx = [i * 2 + 1 for i in range(NN)]
    idx1 = []
    for i in range(N):
        if A[i] <= NN:
            idx1.append(i)
    ans = 0
    for i in range(NN):
        ans += abs(idx[i] - idx1[i])

else:
    NN = N // 2
    idx1 = [i * 2 for i in range(NN)]
    idx2 = [i * 2 + 1 for i in range(NN)]
    idx3 = []
    for i in range(N):
        if A[i] <= NN:
            idx3.append(i)
    ans1 = 0
    for i in range(NN):
        ans1 += abs(idx3[i] - idx1[i])
    
    ans2 = 0
    for i in range(NN):
        ans2 += abs(idx3[i] - idx2[i])
    ans = min(ans1, ans2)
print(NN, ans)
exit()
0