Practice for Microsoft 2015 Online Test register

Ended

Participants:1406

Verdict:Accepted
Score:100 / 100
Submitted:2014-10-18 12:27:40

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<malloc.h>    
int main()    
{    
    int n,m,t;    
    scanf("%d",&t);    
     
    int*array;    
    int ans;    
    for(int tt=0;tt<t;tt++)    
    {    
     scanf("%d%d",&n,&m);    
    ans=0;  
        array=(int*)malloc(n*sizeof(int));    
    int i;    
    for(i=0;i<n;i++)    
        scanf("%d",&array[i]);    
    if(n<=m)    
        ans=100;    
    else    
    {    
        ans=array[m]-1;    
        for(int kk=0;kk<n-m-1;kk++)    
            if(array[kk+m+1]-array[kk]>ans)    
            ans=array[kk+m+1]-array[kk]-1;    
        if(100-array[n-m]>ans)    
        ans=100-array[n-m];    
          
            
    }    
     printf("%d\n",ans);   
      free(array);             
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX