結果

問題 No.2029 Swap Min Max Min
ユーザー momoyuu
提出日時 2022-08-17 21:51:08
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,132 bytes
コンパイル時間 3,251 ms
コンパイル使用メモリ 247,968 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-05 03:08:06
合計ジャッジ時間 7,123 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 27 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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