結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 21 ms
6,944 KB
testcase_06 AC 43 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 28 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 66 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 62 ms
6,944 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 62 ms
6,944 KB
testcase_20 AC 62 ms
6,940 KB
testcase_21 AC 62 ms
6,940 KB
testcase_22 AC 61 ms
6,944 KB
testcase_23 AC 63 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 64 ms
6,944 KB
testcase_26 AC 64 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
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 2 ms
6,940 KB
testcase_32 WA -
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 54 ms
6,940 KB
testcase_39 AC 61 ms
6,944 KB
testcase_40 AC 54 ms
6,944 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 59 ms
6,944 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
    rep(i,0,m){
        if (N%2 == 0 && i == m-1 && b[i] != N){
            ans --;
        }
        ans += abs(2*i+1-b[i]);
    }
    if (N % 2 == 0){

        ll aa = 0;
        rep(i,0,m){
    if (N%2 == 0 && i == 0 && b[i] != 0){
            ans --;
        }
            aa += abs(2*i-b[i]);
        }
        ans = min(aa,ans);
    }
    cout << m << " " << ans << endl;
    
    //system("pause");
    return 0;
}
0