**Problem Statement**

Time is running out. You have a final match to play as a counter terrorist. You have

**ID**from

**snipers**. Find the maximum number of players that you can choose.

**Input Format**

The first line contains

**snipers**).

The second line contains

**IDs**of the snipers.

*NOTE: There are no two snipers with consecutive numbers.*

**Constraints**

**ID of each sniper**

**Output Format**

You need to print the maximum number of players that you can have in your team.

**Sample Input**

` `

```
8 2
6 2
```

**Sample Output**

` `

```
4
```

**Explanation**

There are

To maximize the number of players in the team, you will choose the players with IDs

_{Camper: A player in a professional team dedicated to using the AWP sniper rifle.}

#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int compare(const void * a, const void * b) { return (*(long long int*)a>*(long long int*)b); } int main() { long long int n,k,i,d,sum=0,e; scanf("%lld %lld",&n,&k); long long int s[k]; for(i=0;i<k;i++) { scanf("%lld",&s[i]); } qsort(s,k,sizeof(long long int),compare); d=s[0]-0; if((d-2)%2>0){ e = ((d-2)%2); sum += e; } if((d-2)/2>0){ e=((d-2)/2); sum += e; } d=n-s[k-1]; if((d-1)%2>0){ e=((d-1)%2); sum += e; } if((d-1)/2>0){ e=((d-1)/2); sum += e; } for(i=1;i<k;i++){ d=s[i]-s[i-1]; if((d-3)/2>0){ e=((d-3)/2); sum += e; } if((d-3)%2>0){ e=((d-3)%2); sum += e; } } printf("%lld",sum+k); return 0; }

## Comments

## Post a Comment