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

16MS水过……

Posted by sogo at 2010-02-25 19:53:02 on Problem 3663
#include"stdio.h"
#include"algorithm"
using namespace std;
int main()
{
	int n,s,t,i,j;
	int a[20002];
	int count=0;
	scanf("%d%d",&n,&s);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	j=n-1;
	for(i=0;i<n-1;i++)
	{
		if(a[i]>=s) break;
		while(a[i]+a[j]>s)
			j--;
		if(j<=i)
			break;
			count+=(j-i);
	}
	printf("%d\n",count);
	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