Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n;
  5. int main()
  6. {
  7. int t;
  8. scanf("%d",&t);
  9. for(int i=1; i<=t; i++)
  10. {
  11.  
  12. scanf("%d",&n);
  13. int arr[100005],test=1,dif=0;
  14. arr[0]=0;
  15.  
  16. for(int j=1; j<=n; j++)
  17. {
  18. scanf("%d",&arr[j]);
  19. if(n==1)
  20. {
  21. printf("Case %d: %d\n",i,arr[1]);
  22. test=0;
  23. break;
  24. }
  25. if(arr[j]-arr[j-1]>dif)
  26. dif=arr[j]-arr[j-1];
  27. }
  28. if(test==0)continue;
  29. int ans=dif;
  30. for(int j=1;j<=n;j++)
  31. {
  32. if(arr[j]-arr[j-1]==dif)
  33. {
  34. dif--;
  35. }
  36. else if(arr[j]-arr[j-1]>dif)
  37. {
  38. ans++;
  39. break;
  40. }
  41.  
  42. }
  43.  
  44. printf("Case %d: %d\n",i,ans);
  45.  
  46. }
  47. return 0;
  48. }
  49. /*
  50. 28
  51. 57 150 167 234 322 359 397 481 580 640 692 723 822 898 939 1018 1076 1123 1222 1290 1304 1327 1411 1467 1556 1557 1616 1623
  52. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement