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:贪心大水题

Posted by xz816111 at 2015-04-28 16:14:00 on Problem 3069
In Reply To:贪心大水题 Posted by:13408100238 at 2014-08-08 08:56:45
> #include"iostream"
> #include"cstdio"
> #include"cstring"
> #include"algorithm"
> using namespace std;
> const int ms=1001;
> int a[ms];
> int r,n;
> void solve()
> {
> 	int i=0,ans=0,l;
> 	sort(a,a+n);
> 	l=a[0];
> 	while(i<n)
> 	{
> 		while(i<n&&l+r>=a[i])
> 			i++;
> 		l=a[i-1];
> 		while(i<n&&l+r>=a[i])
> 			i++;
> 		l=a[i];
> 		ans++;
> 	}
> 	printf("%d\n",ans);
> 	return ;
> }
> int main()
> {
> 	while(scanf("%d%d",&r,&n)==2)
> 	{
> 		if(r==-1&&n==-1)
> 			break;
> 		for(int i=0;i<n;i++)
> 			scanf("%d",&a[i]);
> 		solve();
> 	}
> 	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