美文网首页
1003超出时长

1003超出时长

作者: SexySmallMonkey | 来源:发表于2017-04-15 14:44 被阅读7次

    import java.util.Scanner;

    public class Main{

    public static void main(String[] args){

    Scanner input = new Scanner(System.in);

    int n = input.nextInt();

    int temp = 0;

    int start = 0;

    int end = 0;

    for(int i = 0; i < n; i ++){

    int m = input.nextInt();

    int[] myList = new int [100000];

    for(int p = 0; p < m; p++ ){

    myList[p] = input.nextInt();

    }

    int max = myList[0];

    for( int j = 0; j < m; j++ ){

    temp = myList[j];

    for(int k = j+1; k < m; k++){

    temp += myList[k];

    if(max < temp){

    max = temp;

    start = j+1;

    end = k+1;

    }

    }

    }

    System.out.println("case "+(i+1)+":");

    System.out.println(max + " " + start + " " + end);

    for( int l = 0; l < m; l++){

    myList[l] = 0;

    }

    }

    input.close();

    }

    }

    相关文章

      网友评论

          本文标题:1003超出时长

          本文链接:https://www.haomeiwen.com/subject/hewnattx.html