1041A. Heist solution

  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6. long int n;
  7. cin>>n;
  8.  
  9. long long arr[n];
  10. for(int j=0;j<n;j++){cin>>arr[j];}
  11.  
  12. sort(arr,arr+n);
  13.  
  14. int b=arr[0];
  15.  
  16. int l=arr[n-1];
  17.  
  18. int x=0;
  19.  
  20. for(int i=b;i<=l;i++)
  21. {
  22.  
  23. x++;
  24. }
  25.  
  26. cout<<x-n;
  27.  
  28. return 0;
  29. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

1535A. Fair Playoff

Aptitude test assistant programmer 2018