| ||||||||||
| 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: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator