• <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 wenjiajia at 2018-02-06 23:07:12 on Problem 1003
    (616)  


    4 0 0 2 0 —— 2 1 3
    6 2 7 -9 5 4 3 —— 12 1 6
    4 0 0 -1 0 —— 0 1 1
    7 -1 -2 -3 -2 -5 -1 -2 —— -1 1 1
    6 -1 -2 -3 1 2 3 —— 6 4 6
    ----------------------------------------------------------------------------------
    增加一組測試數據:
    5 -3 -2 -1 -2 -3 —— -1 3 3
    
    #include<stdio.h>
    #include<malloc.h>
    #include<string.h>
    
    void main(){
    	int T, N;
    	int t, i;
    	int a[100001];
    	scanf("%d", &T);
    	for(t = 0; t < T; t++){
    		scanf("%d", &N);
    		for(i = 0; i < N; i++)
    			scanf("%d", &a[i]);
    		int maxSum = a[0];
    		int sum = 0, l=0, r=0;
    		int tmpL = 0;
    		for(i = 0; i < N; i++){
    			sum += a[i];
    			if(sum > maxSum){
    				maxSum = sum;
    				l = tmpL;
    				r = i;
    			}
    			if(sum < 0){
    				sum = 0;
    				tmpL = i+1;
    			}
    		}
    		printf("Case %d:\n", t+1);
    		printf("%d %d %d\n", maxSum, l+1, r+1);
    		if(t < T-1)
    			printf("\n");
    	}
    }
    ----------------------------------------------------------------------------------

    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:31:27, Gzip enabled
    棋牌