結果

問題 No.2029 Swap Min Max Min
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-08-06 00:19:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,011 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 201,460 KB
実行使用メモリ 5,620 KB
最終ジャッジ日時 2023-10-14 02:39:30
合計ジャッジ時間 5,741 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 19 ms
4,352 KB
testcase_06 AC 38 ms
4,352 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 11 ms
4,352 KB
testcase_11 WA -
testcase_12 AC 24 ms
4,352 KB
testcase_13 WA -
testcase_14 AC 57 ms
4,628 KB
testcase_15 WA -
testcase_16 AC 55 ms
4,816 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 55 ms
4,708 KB
testcase_20 AC 57 ms
4,532 KB
testcase_21 AC 56 ms
4,612 KB
testcase_22 AC 56 ms
4,600 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 57 ms
4,548 KB
testcase_26 AC 57 ms
4,576 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,348 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 WA -
testcase_39 AC 55 ms
4,628 KB
testcase_40 AC 49 ms
4,368 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 53 ms
4,352 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
    int N;
    cin >> N;
    std::vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    cout << N / 2 << " ";
    if (N % 2) {
        ll ans = 0;
        ll now = 1;
        for (int i = 0; i < N; i ++) {
            if (A[i] <= N / 2) {
                ans += abs(now - i);
                now += 2;
            }
        }
        cout << ans << endl;
    } else {
        ll ans1 = 0;
        ll now = 0;
        vector<ll> B(N / 2);
        for (int i = 0; i < N; i ++) {
            if (A[i] <= N / 2) {
                B[now] = i - now * 2;
                now ++;
                ans1 += abs(B[now]);
            }
        }
        ll ans2 = 0;
        now = 0;
        for (int i = 0; i < N / 2; i ++) {
            if (B[i] > 0) {
                now --;
            } else {
                now ++;
            }
            ans2 = min(ans2, now);
        }
        cout << ans2 + ans1 << endl;
    }
}
0