結果
| 問題 |
No.2029 Swap Min Max Min
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-03 01:01:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 776 bytes |
| コンパイル時間 | 4,004 ms |
| コンパイル使用メモリ | 229,100 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 19:54:35 |
| 合計ジャッジ時間 | 6,895 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 31 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
using ll = long long;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void)
{
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
ll x, y;
x = n / 2;
vector<int> ind;
rep(i, n){
if (a[i] <= x) ind.push_back(i);
}
if(n % 2){
y = 0;
rep(i, x){
y += abs(ind[i] - 2 * i - 1);
}
}
else{
ll y1 = 0;
ll y2 = 0;
rep(i, x){
y1 += abs(ind[i] - 2 * i - 1);
y2 += abs(ind[i] - 2 * i);
}
y = min(y1, y2);
}
cout << x << ' ' << y << endl;
return 0;
}