1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int n; struct node{ int h,w; }a[3005]; bool check(node x,node y){ if(x.h==y.h){ return x.w>=y.w; } else{ return x.h>=y.h; } } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&a[i].h,&a[i].w); } int cnt=0; for(int i=1;i<=n;i++){ for(int j=1;j<=n-i;j++){ if(!check(a[j],a[j+1])){ swap(a[j],a[j+1]); cnt++; } } } printf("%d",cnt); return 0; }
- 1
信息
- ID
- 5520
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者