結果

問題 No.2029 Swap Min Max Min
ユーザー ruthenruthen
提出日時 2022-08-05 22:59:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,024 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 202,040 KB
実行使用メモリ 4,804 KB
最終ジャッジ日時 2023-10-14 00:38:22
合計ジャッジ時間 7,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 8 ms
4,348 KB
testcase_06 AC 15 ms
4,352 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 5 ms
4,348 KB
testcase_11 RE -
testcase_12 AC 10 ms
4,348 KB
testcase_13 RE -
testcase_14 AC 22 ms
4,484 KB
testcase_15 RE -
testcase_16 AC 21 ms
4,460 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 22 ms
4,396 KB
testcase_20 AC 23 ms
4,416 KB
testcase_21 AC 21 ms
4,500 KB
testcase_22 AC 21 ms
4,512 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 20 ms
4,492 KB
testcase_26 AC 20 ms
4,420 KB
testcase_27 RE -
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 RE -
testcase_33 AC 1 ms
4,352 KB
testcase_34 RE -
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 20 ms
4,380 KB
testcase_40 AC 18 ms
4,464 KB
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 19 ms
4,452 KB
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include "debug.hpp"
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    V<int> A(N);
    rep(i, N) cin >> A[i];
    V<int> ind;
    rep(i, N) {
        if (A[i] <= N / 2) {
            ind.push_back(i);
        }
    }
    if (N % 2 == 1) {
        ll ans = 0;
        rep(i, N / 2) ans += abs(ind[i] - (2 * i + 1));
        cout << N / 2 << ' ' << ans << '\n';
    } else {
        assert(0);
        int N2 = N / 2;
        V<ll> dp(N2 + 1), rp(N2 + 1);
        for (int i = 0; i < N2; i++) dp[i + 1] = dp[i] + abs(ind[i] - (2 * i + 1));
        for (int i = N2 - 1; i >= 0; i--) dp[i] = dp[i + 1] + abs(ind[i] - (2 * i));
        ll ans = 1LL << 60;
        rep(i, N2 + 1) ans = min(ans, dp[i] + rp[i]);
        cout << N / 2 << ' ' << ans << '\n';
    }
    return 0;
}
0