Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:怎么老是WA啊,哪个牛人帮我看一下啊!!!

Posted by zhaoru at 2008-08-06 11:04:28 on Problem 1065
In Reply To:怎么老是WA啊,哪个牛人帮我看一下啊!!! Posted by:zhaoru at 2008-08-06 11:03:12
> #include<iostream>
> using namespace std;
> struct wood{
> 	int x;
> 	int y;
> };
> 
> void pa(wood a[],int m){
> 	int i,j;
> 	for(i=0;i<m-1;i++){
> 		int p=i;
> 		for(j=i+1;j<m;j++){
> 			if(a[j].x>a[p].x){ 
> 				p=j;
> 			}
>     		if(a[j].x==a[p].x&&a[j].y>a[p].y){
> 					p=j;
> 			}
> 		}
> 		if(p!=i){
> 			wood k;
> 			k=a[i];a[i]=a[p];a[p]=k;
> 		}
> 	}
> }
> 
> 
> int main(){
> 	int n,k,m,i;int max;
> 	wood a[10000];;
> 
> 	cin>>n;
> 	while(n>0){
> 		cin>>k;
> 		for( i=0;i<k;i++){
> 			cin>>a[i].x>>a[i].y;
> 		}
> 
> 		pa(a,k);max=-1;m=0;
> /*		for( i=0;i<k;i++){
> 			cout<<a[i].x<<a[i].y;
> 		}*/
> 
> 	    for(i=0;i<k;i++){
> 			if(max<a[i].y){
> 				max=a[i].y;
> 				m++;
> 			}
> 		}
> 		n--;
> 		cout<<m<<endl;
> 	}
> 
> 	return 0;
> }
> 
> 
> 
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator