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

超时求解决方法

Posted by 3182052051208 at 2019-11-18 20:35:03 on Problem 1828
#include<stdio.h>
#define N 50000
void main()
{
	int n,a[N],b[N],i,j,t,m=1;
	scanf("%d",&n);
	while(n)
	{
		for(i=0;i<n;i++)
			scanf("%d %d",&a[i],&b[i]);
	for(j=0;j<n-1;j++)
        for(i=0;i<n-1-j;i++)
		{
      if(a[i]>a[i+1])
	  {
         t=a[i];
          a[i]=a[i+1];
          a[i+1]=t;
		  t=b[i];
          b[i]=b[i+1];
          b[i+1]=t;
	  }
	  if(a[i]==a[i+1]&&b[i]>b[i+1])
	  {
		  t=a[i];
          a[i]=a[i+1];
          a[i+1]=t;
		  t=b[i];
          b[i]=b[i+1];
          b[i+1]=t;
	  }
		}
     for(i=n-1;i>=0;i--)
	 {
		 if(a[n-1]>=a[n-2]&&b[n-1]>=b[n-2])
		break;
         if(a[i]==a[i-1]&&b[i]<b[i-1])
               m++;
		 if(a[i]>a[i-1]&&b[i]<b[i-1])
			 m++;
	 }
	 printf("%d\n",m);
	 m=1;
	 scanf("%d",&n);
	}

}

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