• <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 四級還是要報的萬一過了呢... at 2018-02-21 18:56:52 on Problem 1003
    (616)  


    #include<stdio.h>
    #include<string.h>
    #define inf 0x3f3f3f3f
    
    const int maxn=1e5+10;
    int a[maxn];
    
    int main()
    {
    	int t,i,sum,n,head,tail,h1,t1,Max,j;
    	scanf("%d",&t);
    	for(j=1;j<=t;j++)
    	{
    		scanf("%d",&n);
    		for(i=1;i<=n;i++)
    			scanf("%d",&a[i]);
    		head=tail=t1=h1=0;
    		Max=-inf;
    		sum=-1;
    		for(i=1;i<=n;i++)
    		{
    			if(sum>=0)
    			{
    				sum+=a[i];
    				t1++;
    			}
    			else
    			{
    				sum=a[i];
    				h1=t1=i;
    			}
    			if(Max<sum)
    			{
    				Max=sum;
    				head=h1;
    				tail=t1;
    			}
    		}
    		printf("Case %d:\n",j);
    		printf("%d %d %d\n",Max,head,tail);
    		if(j!=t)
    			printf("\n");
    	}
    	return 0;
    }


    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 5, Server time : 2020-11-09 02:31:29, Gzip enabled
    棋牌