30 lines
640 B
C++
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;
|
|
} |