importjava.util.Scanner; publicclassMain{     publicstaticvoidmain(String[] args){         Scanner sc = newScanner(System.in);         intn = 0;         while(sc.hasNext()){             n = sc.nextInt();             int[] num = newint[n];             for(inti=0;i<n;i++){                 num[i] = sc.nextInt();             }             intmax = num[0];             intsum = num[0];             for(inti=1;i<n;i++){                 if(sum>=0){                     sum += num[i];                 }else{                     sum=num[i];                 }                 if(sum>max)max=sum;             }             System.out.println(max);         }     } }
点赞 2

相关推荐

点赞 评论 收藏
分享
牛客网
牛客企业服务