• <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 Adventural at 2018-04-27 13:59:05 on Problem 1003
    (616)  


    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int time,j;
        scanf("%d",&time);
        for(j=0;j<time;j++)
        {
            int i,n,a[100000];
            scanf("%d",&n);
            for(i=0;i<n;i++)
            {
                scanf("%d",&a[i]);
            }
            int min_index=0,max_index=0,sum_maxlist=a[0],sum_cnt=0;
            for(i=0;i<n-1;i++)
            {
                if(a[i+1]>sum_maxlist&&sum_cnt<0)
                {
                    max_index=i+1;
                    min_index=i+1;
                    sum_maxlist=a[i+1];
                    sum_cnt=0;
                }
                else if(a[i+1]+sum_cnt<=0)
                {
                    sum_cnt+=a[i+1];
                }
                else
                {
                    max_index=i+1;
                    sum_maxlist=sum_maxlist+sum_cnt+a[i+1];
                    sum_cnt=0;
                }
    
            }
            printf("Case%d:\n",j+1);
            printf("%d %d %d",sum_maxlist,min_index+1,max_index+1);
            while(j!=time-1)
            {
                printf("\n");
                break;
            }
        }
        return 0;
    }

    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.000000(s) query 4, Server time : 2020-11-09 02:29:46, Gzip enabled
    棋牌