Practice for Microsoft 2015 Online Test register

Ended

Participants:1406

Verdict:Accepted
Score:100 / 100
Submitted:2014-10-18 12:00:36

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 <cstdio>
int main(int argc, char **argv){
    
    int n;
    int abday;
    int cards;
    int abdays[100];
    
    
    scanf("%d",&n);
    while(n>0){
        int count=0;
        int maxdays = 0;
        scanf("%d",&abday);
        scanf("%d", &cards);
        for (int i=0;i<abday;i++){
            scanf("%d", &abdays[i]);        
        }
        
        maxdays = abdays[cards]-1;
     //   printf("now the maxdays is %d", maxdays);
        if (cards >= abday){
            maxdays =100;
        }else{
            for(int i= 0;i<abday-cards-1;i++){
                if(abdays[i+cards+1]-abdays[i]-1 > maxdays){
                    maxdays = abdays[i+cards+1]-abdays[i]-1;
                }
            }
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX