結果

問題 No.2029 Swap Min Max Min
ユーザー momoyuumomoyuu
提出日時 2022-08-17 21:56:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 4,363 ms
コンパイル使用メモリ 277,048 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 09:51:27
合計ジャッジ時間 7,547 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 22 ms
6,944 KB
testcase_06 AC 44 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 13 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 29 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 63 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 63 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 63 ms
6,940 KB
testcase_20 AC 64 ms
6,944 KB
testcase_21 AC 63 ms
6,944 KB
testcase_22 AC 63 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 65 ms
6,940 KB
testcase_25 AC 65 ms
6,948 KB
testcase_26 AC 65 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 WA -
testcase_33 AC 2 ms
6,940 KB
testcase_34 WA -
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 62 ms
6,944 KB
testcase_40 AC 56 ms
6,940 KB
testcase_41 AC 60 ms
6,944 KB
testcase_42 AC 62 ms
6,944 KB
testcase_43 AC 61 ms
6,944 KB
testcase_44 AC 64 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<class t> using vc = vector<t>;
template<class t> using vvc = vc<vc<t>>;
using pi = pair<int,int>;
using vi = vc<int>;
using vvi = vvc<int>;

#define rep(i,a,b) for (int i = a; i < b; i++)
#define irep(i,a,b) for (int i = a; i > b; i--)
#define print(n) cout << n << endl
#define rup(a,b) (a+b-1)/b


int main(){
    cout << fixed << setprecision(15);
    
    int N ;
    cin >> N;
    vi a(N);
    rep(i,0,N) cin >> a[i];
    int m = N / 2;
    vi b(N);
    int now = 0;
    rep(i,0,N){
        if (a[i]>m) continue;
        b[now] = i;
        now ++ ;
    }
    ll ans = 0;
    vc<ll> c(m);
    rep(i,0,m){
        ans += abs(2*i+1-b[i]);
        c[i] = ans;
    }
    if (N%2 == 0){
        ll aa = ans;
        ll na = 0;
        irep(i,m-1,-1){
            na += ans += abs(2*i+1-b[i]);
            if (i!=0){
                aa = min(aa,na+b[i-1]);
            }else{
                aa = min(aa,na);
            }
        }
        ans = aa;
    }
    cout << m << " " << ans << endl;
    
    //system("pause");
    return 0;
}
0