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:悲剧的我终于做到50了,继续努力,贴贴菜鸟代码In Reply To:悲剧的我终于做到50了,继续努力,贴贴菜鸟代码 Posted by:bananas at 2012-05-16 19:47:27 > #include<iostream> > #include<string.h> > #include<algorithm> > using namespace std; > struct Person > { > int a,b,f; > } p[50005]; > bool cmp(const Person&A,const Person&B) > { > if(A.a>B.a||A.a==B.a&&A.b>B.b) > return true; > return false; > } > int main() > { > int n,k; > scanf("%d%d",&n,&k); > memset(p,0,sizeof(p)); > for(int i=0; i<n; i++) > { > scanf("%d%d",&p[i].a,&p[i].b); > p[i].f=i+1; > } > sort(p,p+n,cmp); > int mx=0; > for(int i=1; i<k; i++) > if(p[mx].b<p[i].b) > mx=i; > printf("%d\n",p[mx].f); > system("pause"); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator