Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int n;
- int main()
- {
- int t;
- scanf("%d",&t);
- for(int i=1; i<=t; i++)
- {
- scanf("%d",&n);
- int arr[100005],test=1,dif=0;
- arr[0]=0;
- for(int j=1; j<=n; j++)
- {
- scanf("%d",&arr[j]);
- if(n==1)
- {
- printf("Case %d: %d\n",i,arr[1]);
- test=0;
- break;
- }
- if(arr[j]-arr[j-1]>dif)
- dif=arr[j]-arr[j-1];
- }
- if(test==0)continue;
- int ans=dif;
- for(int j=1;j<=n;j++)
- {
- if(arr[j]-arr[j-1]==dif)
- {
- dif--;
- }
- else if(arr[j]-arr[j-1]>dif)
- {
- ans++;
- break;
- }
- }
- printf("Case %d: %d\n",i,ans);
- }
- return 0;
- }
- /*
- 28
- 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
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement