Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:显然是可以过的啊In Reply To:注意了用sort不一定能过 Posted by:1314199210 at 2013-07-31 16:44:06 > 如题,代码: #include<stdio.h> #include<algorithm> using namespace std; int i,j,k,n; struct ff {int first,second,node;}a[50005]; bool cmp1(ff x,ff y) { if(x.first==y.first) return x.second>y.second; return x.first>y.first; } bool cmp2(ff x,ff y) { if(x.second==y.second) return x.first>y.first; return x.second>y.second; } int main() { scanf("%d %d",&n,&k); for(i=1;i<=n;i++) { scanf("%d %d",&a[i].first,&a[i].second); a[i].node=i; } sort(a+1,a+n+1,cmp1); sort(a+1,a+k+1,cmp2); printf("%d\n",a[1].node); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator