Hihocoder online testing (Google)

Source: Internet
Author: User
Question 1: Time Limit for completing the submission card: Ms single point of time: Ms memory limit: MB description

Mr. Ho has set himself an ambitious goal: to commit a program on hihocoder every day for 100 consecutive days. The first day passed. Xiao ho checked his submission records and found that he had submitted the application for N days. So small ho soft and hard foam, endure the small hi despise eyes from the small hi where to come to M "fill submit card ". Each "makeup card" can be used to make up for one-day submission, changing the day when no program is submitted to another application. Mr. Ho wants to know the maximum number of days for his "Maximum number of consecutive submission Days" by using this m makeup card.

Input

The first line is an integer T (1 <=t <= 10), representing the number of groups of test data.

The first row of each test data is 2 integers n and M (0 <= n, m <= 100 ). The second row contains N integers A1, A2 ,... an (1 <= A1 <A2 <... <An <= 100) indicates the A1, A2 ,... an Tian xiao Ho did not submit the program.

Output

For each group of data, the maximum number of consecutive submission days that can be changed by using the replenishment commit card small Ho is output.

Sample Input
3  5 1  34 77 82 83 84  5 2  10 30 55 56 90  5 10  10 30 55 56 90
Sample output
76  59100

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int a[101];int main(){    int t;    int n, m;    int max;    int i, j;    scanf("%d", &t);    while(t--)    {        scanf("%d %d", &n, &m);        if(n<=m)        {            for(i=0; i<n; i++)            {               scanf("%d", &a[i]);            }           printf("100\n");           continue;        }                for(i=1; i<=n; i++ )        {           scanf("%d", &a[i] );        }        a[0]=0;        int cnt;        max=0;        for(j=m+1; j<=n; j++ )        {            cnt = a[j]-a[j-m-1]-1 ;            if(cnt > max )            max = cnt ;        }        printf("%d\n", max );    }    return 0;}

 

Hihocoder online testing (Google)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.