• <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 adsk47 at 2018-03-12 20:34:56 on Problem 1003
    (616)  


    #include <stdio.h>
    int a[100010];
    int main() {
    	int T,n,i,j,k,cas=1;
    	int start,end,sum,max;
    	scanf("%d",&T);
    	while(T--){
    		scanf("%d",&n);
    		max=-1001;
    		for(i=0;i<n;i++){
    			scanf("%d",&a[i]);
    		}
    		for(i=0;i<n;i++) {
    			for(j=i;j<n;j++) {
    				sum=0;
    				for(k=i;k<=j;k++) {
    					sum+=a[k];
    					if(sum>max) {
    						max=sum;
    						start=i+1;
    						end=j+1;
    					}
    				}
    			}
    		}
    		printf("Case %d:\n",cas++);
    		printf("%d %d %d\n",max,start,end);
    		if(T>0)
    			printf("\n");
    	}
    	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:30:31, Gzip enabled
    棋牌