結果

問題 No.2029 Swap Min Max Min
ユーザー baLoon8128baLoon8128
提出日時 2022-08-05 21:53:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 810 bytes
コンパイル時間 3,886 ms
コンパイル使用メモリ 227,768 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 00:09:32
合計ジャッジ時間 7,191 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

ll solve(const vi &r) {
    int n = r.size();
    ll ret = 0;
    int k = 0;
    rep(i, n) {
        if ((~k & 1) ^ r[i]) {
            ret += i - k;
            k++;
            if (k <= i) k++;
        }
    }
    return ret;
}
int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int x = n / 2;
    rep(i, n) a[i] = (a[i] > x ? 0 : 1);
    ll y = solve(a);
    reverse(a.begin(), a.end());
    y = min(y, solve(a));
    printf("%d %lld\n", x, y);
    return 0;
}
0