hiho week 72 register

Ended

Participants:370

Verdict:Accepted
Score:100 / 100
Submitted:2015-11-15 21:58:27

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
#include<bits/stdc++.h>
#define rep() for(int i=0;i<n;++i)
char c,B[1<<15],*H=B,*T=B;
#define g (H==T&&(T=(H=B)+fread(B,1,1<<15,stdin),H==T)?-1:*H++)
void R(int&v){for(v=c=0;c<48;c=g);for(c^=48;c<=9&&c>=0;c=g^48)v=v*10+c;}
int n,m,h,r,a[100001],cnt,ans;
int main(){
    R(n);R(m);R(h);R(r);rep()R(a[i]);std::sort(a,a+n);
    rep(){if(i&&a[i]-a[i-1]>m)ans+=cnt,cnt=0;if(a[i]>r+cnt)break;++cnt;}
    printf("%d",std::min(ans+cnt,h));
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX