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:几个月前看过,但就是想不明白,今天一见,其实是很简单的题! Posted by:alpc47 at 2008-09-30 16:14:31 无语开始我写成minPrice = 10001了 #include<iostream> #include<algorithm> using namespace std; struct hotel { int D; int C; }; bool cmpFun(hotel a,hotel b); hotel hs[10000]; int main() { int n; while(cin>>n,n) { for(int i = 0 ; i < n ; i ++) scanf("%d %d",&hs[i].D,&hs[i].C); sort(hs,hs + n,cmpFun); int count = 0,minPrice = 10001; for(int i = 0 ; i < n ; i ++) if(hs[i].C < minPrice) minPrice = hs[i].C , count ++; cout<<count<<endl; } return 0; } bool cmpFun(hotel a,hotel b) { if(a.D < b.D) return true; else if(a.D == b.D) return a.C < b.C; else return false; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator