Pabon_SEC

Open Credit System

Feb 23rd, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector<int>vec;
  6.  
  7. int main()
  8. {
  9.     int test,n,i,j,a,mx,res;
  10.  
  11.     scanf("%d",&test);
  12.  
  13.     while(test--)
  14.     {
  15.         scanf("%d",&n);
  16.  
  17.         for(i=1;i<=n;i++)
  18.         {
  19.             scanf("%d",&a);
  20.  
  21.             vec.push_back(a);
  22.         }
  23.  
  24.         int sz = vec.size();
  25.  
  26.         mx = vec[0];
  27.  
  28.         res = vec[0]-vec[1];
  29.  
  30.         for(i=1;i<sz;i++)
  31.         {
  32.             res = max(res,mx-vec[i]);
  33.  
  34.             mx = max(mx,vec[i]);
  35.         }
  36.  
  37.         printf("%d\n",res);
  38.  
  39.         vec.clear();
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment