irregular Egg time limit: 1000 ms | Memory limit: 65535 KB Difficulty: 2 description
We explore the universe to understand the mysteries of the vast stars, but we rarely realize the dangers of hiding in the depths of the universe, and they stare at our earth all the while. If aliens visit us, it may not be the same as when Columbus set foot on the American continent, which is history and reality.
Dormant alien eggs, found on the planet of ZDM-777, differ in appearance from common eggs, and the surface is covered by a layer of graphite. When the person approached, the layer of graphite began to melt, can see the inside of the alien eggs are active, alien eggs are living, with some heat or pressure sensors of the basic central nervous system, by perceiving the surrounding heat, choose the largest parasitic heat. However, if the surrounding is not suitable to be parasitic place, egg-shaped eggs on the choice of dormancy.
Around the heat can be a string of integers a1,a2,......, An to indicate that the egg has a certain length of L, egg-shaped eggs always choose Ai+ai+1+...+ai+l-1 to reach the maximum parasitic. If the surrounding heat is less than 0, the abnormal egg is chosen to hibernate.
How does an alien egg perceive its parasitic place? We explore the universe to understand the mysteries of the vast stars, but we rarely realize the dangers of hiding in the depths of the universe, and they stare at our earth all the while. If aliens visit us, it may not be the same as when Columbus set foot on the American continent, which is history and reality.
Dormant alien eggs, found on the planet of ZDM-777, differ in appearance from common eggs, and the surface is covered by a layer of graphite. When the person approached, the layer of graphite began to melt, can see the inside of the alien eggs are active, alien eggs are living, with some heat or pressure sensors of the basic central nervous system, by perceiving the surrounding heat, choose the largest parasitic heat. However, if the surrounding is not suitable to be parasitic place, egg-shaped eggs on the choice of dormancy.
Around the heat can be a string of integers a1,a2,......, An to indicate that the egg has a certain length of L, egg-shaped eggs always choose Ai+ai+1+...+ai+l-1 to reach the maximum parasitic. If the surrounding heat is less than 0, the abnormal egg is chosen to hibernate.
How does an alien egg perceive its parasitic place? Enter the 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, output one line: Alien eggs can parasitic starting position. If there are many parasitic, then choose a small starting position. If there is nowhere to parasitic, then output 0. Sample input
530 0 100-30 1003 5-100 80-80-100 80
Sample output
30
#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
int k,l,n,i,j,sta,max,sum;
int a[1005];
scanf ("%d", &k);
while (k--)
{
scanf ("%d%d", &l,&n);
sta=max=0;
for (i=1;i<=n;i++)
scanf ("%d", &a[i]);
for (i=1;i<=n-l+1;i++)
{
sum=0;
for (j=0;j<l;j++)
{
sum+=a[i+j];
}
printf ("%d%d\n", i,sum);
if (Sum>max) {max=sum; sta=i}}
}
printf ("%d\n", STA);
}