結果

問題 No.2029 Swap Min Max Min
ユーザー tassei903tassei903
提出日時 2022-08-08 08:03:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 113,368 KB
最終ジャッジ日時 2023-10-18 23:18:13
合計ジャッジ時間 7,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,556 KB
testcase_01 AC 41 ms
53,556 KB
testcase_02 AC 36 ms
53,556 KB
testcase_03 AC 84 ms
96,868 KB
testcase_04 AC 57 ms
73,188 KB
testcase_05 AC 59 ms
78,932 KB
testcase_06 AC 75 ms
97,560 KB
testcase_07 AC 100 ms
100,336 KB
testcase_08 AC 99 ms
112,684 KB
testcase_09 AC 61 ms
79,460 KB
testcase_10 AC 51 ms
70,708 KB
testcase_11 AC 66 ms
84,260 KB
testcase_12 AC 62 ms
84,840 KB
testcase_13 AC 97 ms
107,764 KB
testcase_14 AC 93 ms
112,880 KB
testcase_15 AC 101 ms
111,992 KB
testcase_16 AC 94 ms
111,336 KB
testcase_17 AC 98 ms
107,716 KB
testcase_18 AC 102 ms
112,188 KB
testcase_19 AC 89 ms
111,488 KB
testcase_20 AC 93 ms
112,616 KB
testcase_21 AC 92 ms
112,568 KB
testcase_22 AC 90 ms
111,304 KB
testcase_23 AC 95 ms
112,188 KB
testcase_24 AC 94 ms
112,188 KB
testcase_25 AC 87 ms
111,684 KB
testcase_26 AC 86 ms
111,652 KB
testcase_27 AC 35 ms
53,556 KB
testcase_28 AC 35 ms
53,556 KB
testcase_29 AC 36 ms
53,556 KB
testcase_30 AC 36 ms
53,556 KB
testcase_31 AC 36 ms
53,556 KB
testcase_32 AC 37 ms
53,556 KB
testcase_33 AC 35 ms
53,556 KB
testcase_34 AC 35 ms
53,556 KB
testcase_35 AC 36 ms
53,556 KB
testcase_36 AC 35 ms
53,556 KB
testcase_37 AC 42 ms
53,556 KB
testcase_38 AC 88 ms
111,704 KB
testcase_39 AC 86 ms
110,608 KB
testcase_40 AC 82 ms
105,348 KB
testcase_41 AC 92 ms
113,176 KB
testcase_42 AC 91 ms
113,368 KB
testcase_43 AC 84 ms
110,028 KB
testcase_44 AC 94 ms
112,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n = ni()
a = na()
b = []
def f(p,q):
    r = 0
    for i in range(len(p)):
        r += abs(p[i]-q[i])
    return r

for i in range(n):
    if a[i] <= n//2:
        b.append(i)
if n % 2:
    c = list(range(1,n,2))
    print(n//2,f(b,c))
else:
    p = [0]
    for i in range(n//2):
        p.append(p[-1] + abs(b[i] - i * 2 - 1))
    ans = p[-1]
    x = 0
    for i in range(n//2-1,-1,-1):
        x += abs(b[i]-2*i)
        #print(b[i],2*i,p[i],x)
        ans = min(ans, p[i] + x)
    print(n//2,ans)
0