Saleh127

Untitled

May 9th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int b,c,d,e,f,t,i,j,k,l;
  6. cin>>t;
  7. for(l=1;l<=t;l++)
  8. {
  9. e=0;
  10. d=0;
  11. f=0;
  12. cin>>b;
  13. int a[b+5];
  14. a[0]=0;
  15. for(i=1;i<=b;i++)
  16. {
  17. cin>>a[i];
  18. }
  19. for(i=1;i<=b;i++)
  20. {
  21. c=a[i]-a[i-1];
  22. if(c>d)
  23. {
  24. d=c;
  25. }
  26. }
  27. e=d;
  28. for(i=1;i<=b;i++)
  29. {
  30. f=a[i]-a[i-1];
  31. if(f==d)
  32. {
  33. d--;
  34. }
  35. else if(f>d)
  36. {
  37. e++;
  38. break;
  39. }
  40. }
  41. printf("Case %d: %d\n",l,e);
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment