zoukankan      html  css  js  c++  java
  • 异形卵

    简单题.  不过读题 很重要.

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<math.h>
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<queue>
     7 #include<vector>
     8 #include<set>
     9 #include<stack>
    10 #include<string>
    11 #include<sstream>
    12 #include<map>
    13 #include<cctype>
    14 #include<limits.h>
    15 using namespace std;
    16 int main()
    17 {
    18     int t,l,n,a[1005],maxn,mark,flag,location;
    19     scanf("%d",&t);
    20     while(t--)
    21     {
    22         scanf("%d%d",&l,&n);   //  长度 为 l  的最大值 .
    23         for(int i=0;i<n;i++)
    24             scanf("%d",&a[i]);
    25         maxn=INT_MIN;
    26         for(int i=mark=flag=0;i<n;i++)
    27         {
    28             mark++;
    29             flag+=a[i];
    30             if(mark>=l)
    31             {
    32                 if(maxn<flag)
    33                 {
    34                     maxn=flag;
    35                     location=i;
    36                 }
    37                 flag-=a[i+1-l];
    38                 mark--;
    39             }
    40         }
    41         if(maxn<0)
    42             printf("0
    ");
    43         else
    44             printf("%d
    ",location+2-l);
    45     }
    46     return 0;
    47 }
  • 相关阅读:
    HGE tutorial04
    HGE tutorial03
    HGE tutorial02 plus
    HGE tutorial02
    C 语言实例
    C 语言实例
    C 语言实例
    C 语言实例
    C 语言实例
    C 语言实例
  • 原文地址:https://www.cnblogs.com/A-FM/p/5523459.html
Copyright © 2011-2022 走看看