• <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 GodZzY at 2017-11-25 14:43:59 on Problem 1003
    (616)  


    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    int main() {
    	int T, N,i;
    	int iiii = 1;
    	int Max, sum,num,begin,end;
    	int sumb, sume;
    	cin >> T;
    	while (T--) {
    		Max = 0;
    		sum = 0;
    		cin >> N;
    		begin = 0; end = 0;
    		for (i = 0; i < N; i++) {
    			cin >> num;
    			if (i == 0) {
    				Max = num; sumb = i; sume = i;
    			}
    			sum += num;
    			if (sum > Max) {
    				begin = sumb;
    				end = i;
    			}
    			Max = max(Max,sum);
    			
    			if (sum < 0) {
    				sumb = i+1;
    				sum = 0;
    			}
    		}
    		cout << "Case " << iiii++ << ":" << endl;
    		cout << Max << ' ' << begin + 1 << ' ' << end + 1 << endl;
    		if (T != 0)cout << endl;
    
    
    	}
    	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:54, Gzip enabled
    棋牌