ghorardim

loj-1425 - The Monkey and the Oiled Bamboo

Oct 28th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. #include<ctype.h>
  5. #include<stdlib.h>
  6. #include<cstdio>
  7. #include<cstring>
  8. #include<string>
  9. #include<cmath>
  10. #include<iostream>
  11. #include<cctype>
  12. #include<map>
  13. #include<stack>
  14. #include<cstdlib>
  15. #include<queue>
  16. #include<vector>
  17. #include<algorithm>
  18. #include<bitset>
  19. #include<algorithm>
  20. #include<set>
  21. #include<limits.h>
  22.  
  23. using namespace std;
  24. typedef long int LD;
  25. typedef long long int LLD;
  26. typedef float F;
  27. typedef double LF;
  28. typedef unsigned int U;
  29. typedef unsigned long int LU;
  30. typedef unsigned long long int LLU;
  31. typedef char C;
  32.  
  33.  
  34. /*----------simple input section ------------ */
  35. #define sf scanf
  36. #define sfi(x) scanf("%d",&x)
  37. #define sfc(x) scanf("%c",&x)
  38. #define sfi2(x,y) scanf("%d%d",&x,&y)
  39. #define sfl(x) scanf("%ld",&x)
  40. #define sfll(x) scanf("%lld",&x)
  41. #define sfd(x) scanf("%lf",&x)
  42. #define sfu(x) scanf("%llu",&x)
  43. #define sfs(x) scanf("%s",x)
  44.  
  45.  
  46. /*----------simple input section ------------ */
  47. #define pf printf
  48. #define pfi(x) printf("%d\n",x)
  49. #define pfl(x) printf("%ld\n",x)
  50. #define pfll(x) printf("%lld\n",x)
  51. #define pfu(x) printf("%llu\n",x)
  52. #define pfs(x) printf("%s\n",x)
  53. #define pfc(x) printf("%c\n",x)
  54. #define pfd(x) printf("%lf\n",x)
  55.  
  56. /*----------file input section ------------ */
  57.  
  58. #define f_input  freopen("input.txt","r",stdin);
  59. #define f_output freopen("output.txt","w",stdout);
  60.  
  61. #define pb(x) push_back(x)
  62. #define PI acos(-1.0)
  63. #define sq(x) (x)*(x)
  64. #define mem(x,y) memset(x,y,sizeof(x))
  65. #define TEST int cs,T;sfi(T);getchar();for(cs=1;cs<=T;cs++)
  66. #define nn printf("\n")
  67. // xx-> diagonal -> 8 horizontal/vertical->4
  68.  
  69. const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
  70. const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
  71.  
  72. // KX-> Knight moves
  73. const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
  74. const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
  75.  
  76.  
  77. /******** debug **********/
  78. #define chk1 printf("hi......1  \n")
  79. #define chk2 printf("hi......2  \n")
  80.  
  81.  
  82.  
  83.  
  84. #define mod 1000003
  85. #define eps 10e-8
  86. #define sz 50004
  87. #define sz1 55
  88. #define sz2 1004
  89. /******* start my code ********/
  90.  
  91. int main()
  92. {
  93.     LLD i,j,k,n,m,mx,cnt,mn,a;
  94.     TEST
  95.     {
  96.         sfll(n);
  97.         mx=0;
  98.         m=0;
  99.         cnt=0;
  100.         mn=1000000003;
  101.         for(i=0; i<n; i++)
  102.         {
  103.             sfll(a);
  104.             if(mx<(a-m))
  105.             {
  106.                 mx=a-m;
  107.                 k=mx-1;
  108.             }
  109.             else
  110.             {
  111.                 if(k==(a-m)) k--;
  112.                 else if(k<(a-m))
  113.                 {
  114.                     mx++;
  115.                     k=mx-1;
  116.                 }
  117.             }
  118.             m=a;
  119.         }
  120.         pf("Case %d: ",cs);
  121.         pfll(mx);
  122.     }
  123.     return 0;
  124.  
  125. }
  126. /*
  127.  
  128. */
Advertisement
Add Comment
Please, Sign In to add comment