結果

問題 No.2029 Swap Min Max Min
ユーザー HaaHaa
提出日時 2022-08-05 21:39:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 867 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 168,684 KB
実行使用メモリ 5,956 KB
最終ジャッジ日時 2023-10-14 00:05:23
合計ジャッジ時間 4,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 20 ms
4,352 KB
testcase_06 AC 39 ms
5,204 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 12 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 26 ms
4,352 KB
testcase_13 WA -
testcase_14 AC 58 ms
5,612 KB
testcase_15 WA -
testcase_16 AC 57 ms
5,552 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 58 ms
5,580 KB
testcase_20 AC 58 ms
5,588 KB
testcase_21 AC 58 ms
5,644 KB
testcase_22 AC 57 ms
5,864 KB
testcase_23 AC 59 ms
5,608 KB
testcase_24 AC 59 ms
5,588 KB
testcase_25 AC 59 ms
5,584 KB
testcase_26 AC 58 ms
5,608 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,352 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 1 ms
4,352 KB
testcase_38 AC 51 ms
5,484 KB
testcase_39 AC 57 ms
5,488 KB
testcase_40 AC 51 ms
5,460 KB
testcase_41 AC 53 ms
5,616 KB
testcase_42 AC 53 ms
5,776 KB
testcase_43 AC 55 ms
5,548 KB
testcase_44 AC 58 ms
5,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i], a[i]--;
    int x=n/2;
    VI b;
    REP(i,n){
        if(a[i]<x)
            b.push_back(i);
    }
    ll ans=INF, s;
    if(n%2==0){
        s=0;
        REP(i,n/2){
            s+=abs(i*2-b[i]);
        }
        chmin(ans,s);
    }
    s=0;
    REP(i,n/2){
        s+=abs(i*2+1-b[i]);
    }
    chmin(ans,s);
    cout << x << " " << ans << endl;
    return 0;
}
0