SHARE
TWEET

Untitled

a guest Jan 17th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7.     int t,i,max,n,r,p,j,arr[200],ans;
  8.     int gap,k;
  9.     arr[0]=0;
  10.     cin>>t;
  11.     for(k=0; k<t; k++)
  12.     {
  13.         max=0;
  14.         cin>>n>>r>>p;
  15.         for(i=1; i<=n; i++)
  16.         {
  17.             cin>>arr[i];
  18.         }
  19.         arr[i]=r;
  20.  
  21.         sort(arr,arr+(n+2));
  22.         for(j=1; j<=(n+1); j++)
  23.         {
  24.             gap=arr[j]-arr[j-1];
  25.             if(gap>max)
  26.             {
  27.                 max=gap;
  28.             }
  29.  
  30.         }
  31.         if(max>p)
  32.         {
  33.             ans=max-p;
  34.             cout<<ans<<endl;
  35.         }
  36.         else
  37.         {
  38.             ans=0;
  39.             cout<<ans<<endl;
  40.         }
  41.         return 0;
  42.     }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top