1 条题解
-
0
C++ :
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct fun { int length; int weight; } s[5010]; int cmp(fun a,fun b) { if(a.length!=b.length) return a.length<b.length; else return a.weight<b.weight; } int main() { int n,m,count,end,j; //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); cin>>n; while(n--) { count=0; cin>>m; for(int i=0; i<m; i++) cin>>s[i].length>>s[i].weight; sort(s,s+m,cmp); for(int i=0; i<m; i++) { end=s[i].weight; if(s[i].weight!=0) { for(j=i+1; j<m; j++) if(s[j].weight>=end) { end=s[j].weight; s[j].weight=0; } count++; } } cout<<count<<endl; } }
- 1
信息
- ID
- 3347
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者