0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#137. 【2020.11.28 NOIP模拟赛 T2】交换

https://sjzezoj.com/submission/70885
This commit is contained in:
Baoshuo Ren 2023-02-17 16:27:27 +08:00
parent 8dbd7b2da0
commit 3ecf91301d
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
42 changed files with 172 additions and 0 deletions

49
S2OJ/137/137.cpp Normal file
View File

@ -0,0 +1,49 @@
#include <iostream>
#include <numeric>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 3e5 + 5;
int n, a[N], c1[N], c2[N], ans[N];
int lowbit(int x) {
return x & -x;
}
void add(int* c, int x, int y) {
for (; x <= n; x += lowbit(x)) c[x] += y;
}
int sum(int* c, int x) {
int res = 0;
for (; x; x -= lowbit(x)) res += c[x];
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
ans[i] = sum(c1, n) - sum(c1, a[i]);
add(c1, a[i], 1);
}
for (int i = n; i; i--) {
ans[i] = std::min(ans[i], sum(c2, n) - sum(c2, a[i]));
add(c2, a[i], 1);
}
cout << std::accumulate(ans + 1, ans + 1 + n, 0ll) << endl;
return 0;
}

BIN
S2OJ/137/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/137/data/psy9.in (Stored with Git LFS) Normal file

Binary file not shown.