Henan Province Sixth annual ACM Provincial Irregular Egg (violence)

Source: Internet
Author: User

Irregular egg time limit: +Ms | Memory Limit:65535KB Difficulty:2
Describe

We explore the universe to understand the wonders of the starry sky, but we are seldom aware of the dangers of hiding in the depths of the universe, staring at our earth all the while. If aliens visit us, the results may not be the same as when Columbus was on the American continent, which is history and reality.

The dormant irregular eggs found on the planet ZDM-777, whose appearance is different from the common eggs, are covered with a layer of graphite. When the person approached, the layer of graphite began to melt, can see the inside of the alien eggs are moving, irregular eggs are living things, with some heat or pressure sensor these basic central nervous system, by perceiving the heat around, select the maximum parasitic heat. However, if the surrounding area is not suitable for the parasite, irregular eggs will choose to sleep.

The surrounding heat can be expressed by a string of integers a1,a2,......, An, the irregular eggs have a certain length of L, the irregular eggs are always selected ai+ai+1+...+ai+l-1 to reach the maximum value of parasitic. If the surrounding heat is less than 0, the irregular eggs are selected for hibernation.

How does an irregular egg perceive its parasitic place? We explore the universe to understand the wonders of the starry sky, but we are seldom aware of the dangers of hiding in the depths of the universe, staring at our earth all the while. If aliens visit us, the results may not be the same as when Columbus was on the American continent, which is history and reality.

The dormant irregular eggs found on the planet ZDM-777, whose appearance is different from the common eggs, are covered with a layer of graphite. When the person approached, the layer of graphite began to melt, can see the inside of the alien eggs are moving, irregular eggs are living things, with some heat or pressure sensor these basic central nervous system, by perceiving the heat around, select the maximum parasitic heat. However, if the surrounding area is not suitable for the parasite, irregular eggs will choose to sleep.

The surrounding heat can be expressed by a string of integers a1,a2,......, An, the irregular eggs have a certain length of L, the irregular eggs are always selected ai+ai+1+...+ai+l-1 to reach the maximum value of parasitic. If the surrounding heat is less than 0, the irregular eggs are selected for hibernation.

How does an irregular egg perceive its parasitic place?

Input
First line: K indicates how many sets of test data are available.
Next, there are 2 rows for each set of test data, line 1th: L N
Line 2nd: A1 A2 ... an

"Constraint conditions"
2≤k≤5 L≤n, 1≤l≤10 1≤n≤1000-100≤ai≤100
There is a space between the data.

Output
for each set of test data, the output line: The starting position of the parasitic eggs can be. If there are multiple parasitic, select a small starting position. If there is nowhere to parasitic, then output 0.
Sample input
2
3 5
  0 100-30 100
3 5
-100 80-80-100  80
Sample output
30
Source
sixth session of Henan Province Program design Competition
Uploaded by

Acm_ Zhao Minhao


#include <cstdio>
int a[1500];
int l, N;
int main ()
{
int t;
For (scanf ("%d", &t); t--;)
{
scanf ("%d%d", &l, &n);
for (int i = 1; I <= n; i++)
{
scanf ("%d", &a[i]);
}
int pos = 0;
int ans, MAXV =-1;
for (int i = 1; I <= n-l + 1; i++)//First I.
{
Ans = 0;
for (int j = i; J <= L + i-1; j + +)//Backward push L
{
Ans + = a[j];
}
if (Ans > MAXV)
{
MAXV = ans;
pos = i;
}
}
if (POS)
printf ("%d\n", POS);
Else
printf ("0\n");
}


return 0;
}

Henan Province Sixth annual ACM Provincial Irregular Egg (violence)

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.