Skip to content

Instantly share code, notes, and snippets.

@joemmanuel
Created September 17, 2013 16:34
Show Gist options
  • Select an option

  • Save joemmanuel/6596898 to your computer and use it in GitHub Desktop.

Select an option

Save joemmanuel/6596898 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <stdio.h>
using namespace std;
int arr[50];
int n,i,a,b,c;
int main()
{
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
// Ordernar la entrada
sort(arr,arr+n);
// Determinar A y B como el mínimo y el máximo que vimos
a=arr[0];
b=arr[n-1];
// Contar los patos que nos faltan en el intervalo A B
c=(b-a+1)-n;
printf("%d",c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment