結果

問題 No.2029 Swap Min Max Min
ユーザー ntudantuda
提出日時 2022-08-10 20:19:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 109,588 KB
最終ジャッジ日時 2023-10-21 05:32:38
合計ジャッジ時間 6,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,520 KB
testcase_01 AC 41 ms
53,520 KB
testcase_02 AC 39 ms
53,520 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 59 ms
74,956 KB
testcase_06 AC 73 ms
90,772 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 52 ms
67,956 KB
testcase_11 WA -
testcase_12 AC 62 ms
80,116 KB
testcase_13 WA -
testcase_14 AC 87 ms
103,316 KB
testcase_15 WA -
testcase_16 AC 86 ms
102,736 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 89 ms
102,784 KB
testcase_20 AC 86 ms
103,004 KB
testcase_21 AC 87 ms
103,148 KB
testcase_22 AC 85 ms
102,736 KB
testcase_23 WA -
testcase_24 AC 97 ms
109,456 KB
testcase_25 AC 82 ms
102,996 KB
testcase_26 AC 83 ms
103,000 KB
testcase_27 RE -
testcase_28 AC 39 ms
53,520 KB
testcase_29 AC 39 ms
53,520 KB
testcase_30 AC 38 ms
53,520 KB
testcase_31 AC 38 ms
53,520 KB
testcase_32 AC 39 ms
53,520 KB
testcase_33 AC 38 ms
53,520 KB
testcase_34 WA -
testcase_35 AC 38 ms
53,520 KB
testcase_36 AC 38 ms
53,520 KB
testcase_37 AC 38 ms
53,520 KB
testcase_38 WA -
testcase_39 AC 83 ms
102,772 KB
testcase_40 AC 77 ms
97,040 KB
testcase_41 AC 94 ms
106,664 KB
testcase_42 AC 95 ms
106,676 KB
testcase_43 AC 81 ms
102,608 KB
testcase_44 AC 97 ms
109,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
X = N // 2
if N & 1:
    st = 1
    Y = 0
    for i,a in enumerate(A):
        if a <= X:
            Y += abs(st-i)
            st += 2
else:
    dp = [[0]*2 for _ in range(N//2)]
    j = 0
    for i,a in enumerate(A):
        if a <= X:
            dp[j][0] = dp[j-1][0] + abs(j*2-i)
            dp[j][1] = min(dp[j-1][0],dp[j-1][1]) + abs(j*2+1-i)
            j += 1
    Y = min(dp[-1][0],dp[-2][1])
print(X,Y)
0