結果

問題 No.2029 Swap Min Max Min
ユーザー 👑 KazunKazun
提出日時 2022-08-05 23:14:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 114,696 KB
最終ジャッジ日時 2023-10-14 01:03:32
合計ジャッジ時間 7,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,304 KB
testcase_01 AC 71 ms
71,596 KB
testcase_02 AC 70 ms
71,440 KB
testcase_03 AC 112 ms
96,388 KB
testcase_04 AC 90 ms
79,360 KB
testcase_05 AC 89 ms
87,048 KB
testcase_06 AC 107 ms
101,920 KB
testcase_07 AC 117 ms
99,400 KB
testcase_08 AC 134 ms
110,212 KB
testcase_09 AC 98 ms
83,848 KB
testcase_10 AC 87 ms
80,784 KB
testcase_11 AC 102 ms
87,560 KB
testcase_12 AC 95 ms
91,076 KB
testcase_13 AC 136 ms
110,572 KB
testcase_14 AC 122 ms
108,860 KB
testcase_15 AC 135 ms
114,468 KB
testcase_16 AC 123 ms
114,480 KB
testcase_17 AC 132 ms
110,164 KB
testcase_18 AC 132 ms
108,596 KB
testcase_19 AC 116 ms
108,432 KB
testcase_20 AC 122 ms
108,288 KB
testcase_21 AC 121 ms
108,564 KB
testcase_22 AC 122 ms
114,488 KB
testcase_23 AC 123 ms
114,648 KB
testcase_24 AC 120 ms
108,968 KB
testcase_25 AC 121 ms
114,696 KB
testcase_26 AC 118 ms
108,652 KB
testcase_27 AC 71 ms
71,380 KB
testcase_28 AC 71 ms
71,560 KB
testcase_29 AC 71 ms
71,336 KB
testcase_30 AC 71 ms
71,428 KB
testcase_31 AC 70 ms
71,176 KB
testcase_32 AC 71 ms
71,224 KB
testcase_33 AC 69 ms
71,344 KB
testcase_34 AC 71 ms
71,208 KB
testcase_35 AC 71 ms
71,212 KB
testcase_36 AC 72 ms
71,288 KB
testcase_37 AC 73 ms
71,068 KB
testcase_38 AC 124 ms
110,112 KB
testcase_39 AC 121 ms
114,360 KB
testcase_40 AC 112 ms
109,888 KB
testcase_41 AC 120 ms
110,808 KB
testcase_42 AC 132 ms
110,788 KB
testcase_43 AC 121 ms
114,516 KB
testcase_44 AC 122 ms
108,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N=int(input())
    A=[-1]+list(map(int,input().split()))

    X=N//2; Y=0

    T=[i for i in range(1,N+1) if A[i]<=X]

    if N%2==1:
        for i,t in enumerate(T,1):
            Y+=abs(2*i-t)
    else:
        y=z=0
        for i,a in enumerate(T,1):
            y+=abs(2*i-1-a)
            z+=abs(2*i-a)
        Y=min(y,z)

        for i,a in enumerate(T,1):
            y+=abs(2*i-a)-abs(2*i-1-a)
            Y=min(Y,y)

        for j in range(N//2-1,-1,-1):
            k=j+1; a=T[j]
            z+=abs(2*k-1-a)-abs(2*k-a)
            Y=min(Y,z)

    print(X,Y)

solve()
0