Advertisement
erfanul007

Light OJ 1425

Jan 25th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define scs(s) scanf("%s",s)
  19. #define pfi(n) printf("%d",n)
  20. #define pfl(n) printf("%lld",n)
  21. #define pff(n) cout<<n
  22. #define line printf("\n")
  23. #define spc printf(" ")
  24. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  25. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  26. #define cspf(i) printf("Case %d: ", i)
  27. #define pb push_back
  28. #define mp make_pair
  29. #define ff first
  30. #define ss second
  31. #define all(v) v.begin(),v.end()
  32. #define rall(v) v.rbegin(),v.rend()
  33. #define read() freopen("input.txt", "r", stdin)
  34. #define write() freopen("output.txt", "w", stdout)
  35. /// Constants
  36. #define eps 1e-9
  37. #define PI acos(-1.0) // 3.1415926535897932
  38.  
  39.  
  40. int main()
  41. {
  42. int t;sci(t);
  43. loop(j,1,t){
  44. int last=0,x,n,mx=0,dis,k;
  45. sci(n);
  46. vi ds(n);
  47. loop(i,0,n-1){
  48. sci(x);
  49. dis=x-last;
  50. ds[i]=dis;
  51. if(mx<dis){
  52. mx=dis;
  53. k=i;
  54. }
  55. last=x;
  56. }
  57. x=mx;
  58. loop(i,k,n-1){
  59. if(ds[i]>x){
  60. x=-1;
  61. break;
  62. }
  63. else if(ds[i]==x){
  64. x--;
  65. }
  66. }
  67. if(x==-1)
  68. mx++;
  69. cspf(j);
  70. pfi(mx);line;
  71. }
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement