diff --git a/Codeforces_Boxers.cpp b/Codeforces_Boxers.cpp new file mode 100644 index 0000000..33e5ad4 --- /dev/null +++ b/Codeforces_Boxers.cpp @@ -0,0 +1,81 @@ +#include +#include // Common file +#include // Including tree_order_statistics_node_update +#include +using namespace std; +using namespace __gnu_pbds; +typedef long long int ld; +#define v 150003 +#define mod 1000000007 +#define fori(i,l,n) for(int i=int(l);i=int(l);i--) +#define in(n) scanf("%d",&n); +#define In(n) scanf("%lld",&n); +#define iin(n,m) scanf("%d %d",&n,&m); +#define IIN(n,m) scanf("%lld %lld",&n,&m); +#define Pr(n) printf("%d\n",n); +#define pr(n,m) printf("%d %d\n",n,m); +#define flush fflush(stdout); +#define S(a) a.size() +#define pb push_back +#define sr(a) sort(a.begin(),a.end()) +#define Sr(a,n) sort(a,a+n); +#define rv(a) reverse(a.begin(),a.end()) +#define mp(u,w) make_pair(u,w) +typedef tree,rb_tree_tag,tree_order_statistics_node_update>ordered_set; +priority_queue, vector >,greater > >heapp; +priority_queue >heapp2; +vectortree1[v]; +vector >tree2[v]; +class comp{ + public: + bool operator()(pair n1,pair n2) + { + return(n1.second > n2.second); + } +}; +int main() +{ + int n; + in(n); + vectora(n); + fori(i,0,n) + in(a[i]); + sr(a); + bool c[v]={0}; + int cnt=0; + fori(i,0,S(a)) + { + if(c[a[i]]==0) + { + if(a[i]-1 !=0 && c[a[i]-1]==0) + { + c[a[i]-1]=1; + a[i]--; + cnt++; + } + else + { + cnt++; + c[a[i]]=1; + } + } + else + { + if(a[i]-1!=0 && c[a[i]-1]==0) + { + a[i]--; + c[a[i]]=1; + cnt++; + } + else if(c[a[i]+1]==0 && a[i]+1 <= 150001) + { + a[i]++; + c[a[i]]=1; + cnt++; + } + } + } + Pr(cnt); + return 0; +}