• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    Re:AC附上一組新的測試數組

    Posted by 201601090133 at 2018-05-09 22:55:47 on Problem 1003
    (616)  


    #include<stdio.h>
    int main()
    {
        int i,j=0,x;
        int a[100002];
        int b[100002];
        scanf("%d",&i);
        while(i--)
        {
            int max,k=0;
            j++;
            scanf("%d",&x);
            for(int n=0;n<x;n++)
                scanf("%d",&a[n]);
            for(int m=0;m<x;m++)
            {
                if(m==0)
                {
                   b[m]=a[m];
                   max=a[m];
                   k=m;
                }
                else
                    {
                        if(b[m-1]>0)
                        {
                            b[m]=a[m]+b[m-1];
                        }
                        else
                            b[m]=a[m];
    
                    }
                    if(b[m]>max)
                    {
                        max=b[m];
                        k=m;
                    }
            }
            int d=0;
            for(d=k;d>=0;d--){
    
                 if(b[d]>=0&&d==0){d=1;break;}
                 if(b[d]<0&&b[d+1]<0&&d==0){d=1;break;}
                if(b[d]<0&&d==k){d=d+1;break;}
                if(b[d]<0){d=d+2;break;}
            }
            printf("Case %d:\n",j);
            printf("%d %d %d\n",max,d,k+1);
        }
    }

    Followed by:


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2020 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.015600(s) query 4, Server time : 2020-11-09 02:30:45, Gzip enabled
    棋牌