Files
python/TangDou/CSP-J/AcWingTraining/MaoPao2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
640 B
C++

#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
struct Node {
int height;
int weight;
} a[N];
int res;
bool cmp(Node a, Node b) {
if (a.height != b.height)
return a.height < b.height;
return a.weight < b.weight;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i].height >> a[i].weight;
// 冒泡排序
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (cmp(a[i], a[j])) {
swap(a[i], a[j]);
res++;
}
cout << res << endl;
return 0;
}