Nyoj 709 (zzulioj1481)

Source: Internet
Author: User
Description

We explore the universe to understand the mysteries of the vast starry sky, but we are rarely aware of the dangers of hiding in the depths of the universe, they are always staring at our Earth. If aliens visit us, the result may not be the same as that of Columbus when he stepped onto the continent of America. This is a historical and realistic situation.

The dormant alien eggs found on the planet ZDM-777, whose appearance is different from the common eggs and whose surface is covered by a layer of graphite. When a person approaches, the graphite layer begins to melt, and the shaped eggs inside are active. The shaped eggs are active and have some heat or pressure sensors, which are the basic central nervous system, by perceiving the surrounding heat, you can select the maximum parasitic heat. However, if there are not suitable parasitic locations around, the alien eggs choose to sleep.

You can use a string of integers A1, A2 ,......, According to an, exclusive eggs have a certain length of L, and exclusive eggs always choose ai + AI + 1 +... + AI + L-1 reach the maximum parasitic position. If the surrounding heat is less than 0, the alien eggs choose sleep.

How does an alien egg perceive its parasitic locations?

Input

The first line:K Number of groups of test data.

Next, there will be 2 rows of test data in each group, 1st rows: l n

Row 3: A1 A2 ...... An

Output

For each group of test data, the output line is the starting position where the alien egg can be parasitic. If there are multiple hosts that can be parasitic, select a small starting position. If there is nowhere to be parasitic, 0 is output.

2 ≤ k ≤ 5 L ≤ n, 1 ≤ L ≤ 10 1 ≤ n ≤ 1000-100 ≤ AI ≤ 100

There is a space between data.

Sample Input
23 530  0 100 -30 1003 5-100 80 -80 -100  80
Sample output
30
Prompt

Source

Henan sixth College Student Program Design Competition

Sign-in question, I'm bored with writing, with a prefix

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int a[1100];int n,l;int main(){    int t,temp;;    cin>>t;    while(t--)    {        int sum=0;        cin>>l>>n;        for(int i=1;i<=n;i++)        {            cin>>temp;            sum+=temp;            a[i]=sum;        }        int maxn=0;        int k=0;        for(int i=1;i<=n-l+1;i++)        {            int s=a[i+l-1]-a[i-1];            if(s>maxn)            {                maxn=s;                k=i;            }        }        cout<<k<<endl;    }    return 0;}


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.