結果

問題 No.2029 Swap Min Max Min
ユーザー 👑 KazunKazun
提出日時 2022-08-05 22:57:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 444 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 114,588 KB
最終ジャッジ日時 2023-10-14 00:33:59
合計ジャッジ時間 9,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,980 KB
testcase_01 AC 70 ms
71,236 KB
testcase_02 AC 72 ms
70,844 KB
testcase_03 WA -
testcase_04 AC 92 ms
79,068 KB
testcase_05 AC 92 ms
86,972 KB
testcase_06 AC 112 ms
101,680 KB
testcase_07 WA -
testcase_08 AC 133 ms
110,084 KB
testcase_09 AC 95 ms
82,920 KB
testcase_10 AC 86 ms
80,676 KB
testcase_11 AC 100 ms
87,128 KB
testcase_12 AC 97 ms
90,536 KB
testcase_13 WA -
testcase_14 AC 127 ms
108,568 KB
testcase_15 AC 136 ms
114,180 KB
testcase_16 AC 129 ms
114,420 KB
testcase_17 AC 135 ms
109,924 KB
testcase_18 WA -
testcase_19 AC 126 ms
108,276 KB
testcase_20 AC 127 ms
108,660 KB
testcase_21 AC 126 ms
108,820 KB
testcase_22 AC 128 ms
114,280 KB
testcase_23 AC 124 ms
114,588 KB
testcase_24 AC 123 ms
108,788 KB
testcase_25 AC 122 ms
114,184 KB
testcase_26 AC 118 ms
108,640 KB
testcase_27 AC 68 ms
71,460 KB
testcase_28 AC 71 ms
71,280 KB
testcase_29 AC 70 ms
71,296 KB
testcase_30 AC 71 ms
71,308 KB
testcase_31 AC 70 ms
71,276 KB
testcase_32 AC 69 ms
71,284 KB
testcase_33 AC 70 ms
71,420 KB
testcase_34 WA -
testcase_35 AC 70 ms
71,364 KB
testcase_36 AC 67 ms
71,224 KB
testcase_37 AC 69 ms
71,248 KB
testcase_38 AC 120 ms
110,076 KB
testcase_39 AC 122 ms
114,168 KB
testcase_40 AC 114 ms
109,840 KB
testcase_41 AC 120 ms
110,312 KB
testcase_42 AC 121 ms
110,568 KB
testcase_43 AC 120 ms
114,176 KB
testcase_44 AC 122 ms
108,280 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]
    y=0; z=0
    for i,a in enumerate(T,1):
        y+=abs(2*i-a)
        z+=abs(2*i-1-a)

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

    print(X,Y)

solve()
0