Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class bestindex
- {
- public static void main(String []args)
- {
- Scanner sc=new Scanner(System.in);
- int n=sc.nextInt();
- long arr[]=new long[n];
- long brr[]=new long[n];
- String s="";
- long h=brr[0];
- for(int x=0;x<n;x++)
- {
- s=sc.next();
- arr[x]=Integer.valueOf(s);
- brr[x]=0;
- }
- for(int x=0;x<n;x++)
- {
- int y=x;
- int z=x;
- int c=0;
- while(z<n)
- {
- for(int i=y;i<=z;i++)
- {
- brr[x]=brr[x]+arr[i];
- }
- y=z+1;
- c++;
- z=y+c;
- }
- if(brr[x]>h)
- h=brr[x];
- }
- System.out.print(h);
- }
- }
Add Comment
Please, Sign In to add comment