結果
| 問題 |
No.2029 Swap Min Max Min
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-08-05 21:28:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 643 bytes |
| コンパイル時間 | 4,409 ms |
| コンパイル使用メモリ | 252,452 KB |
| 最終ジャッジ日時 | 2025-01-30 17:40:51 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 31 WA * 11 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
int main() {
int N;
cin>>N;
vector<int> a(N);
vector pos(2,vector<int>());
rep(i,N){
cin>>a[i];
if(a[i]<=N/2)pos[0].push_back(i);
else pos[1].push_back(i);
}
long long ans = 1000000000000000000;
rep(i,2){
if(pos[i].size()==(N+1)/2){
long long sum = 0;
for(int j=0;j<=N-1;j+=2){
sum += abs(pos[i][j/2]-j);
}
ans = min(ans,sum);
}
}
cout<<N/2<<' ';
cout<<ans<<endl;
return 0;
}
沙耶花