<style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px} span.s1 {font-variant-ligatures: no-common-ligatures} span.Apple-tab-span {white-space:pre} </style>
import java.util.*;
public class P2104{
static int[] A;
static int N;
static long max=0;
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
N=sc.nextInt();
A=new int[N];
for(int i=0; i
A[i]=sc.nextInt();
}
select(0,N,A);
System.out.println(max);
}
static long select(int left,int right, int[] A){
long min=100001;
long sum=0;
int temp=0;
if(left>=right)return 0;
for(int i=left; i
sum+=A[i];
if(min>A[i]){
min=A[i];
temp=i;
}
}
sum*=min;
if(max
return select(left,temp,A)+select(temp+1,right,A);
}
}
아아 알겠습니다 ; min값으로 나누면 안되는 case가 있을 수 있네요..