Notice
Recent Posts
문제 풀이 및 개발 공간
[백준] 17216번 가장 큰 감소 부분 수열 본문
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
int n=Integer.parseInt(br.readLine());
int[][] num=new int[n][2];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0; i<n; i++){
num[i][0]=Integer.parseInt(st.nextToken());
}
for(int i=0; i<n; i++){
num[i][1]+=num[i][0];
for(int j=i+1; j<n; j++){
if(num[i][0] > num[j][0] && num[i][1]>num[j][1]){
num[j][1]=num[i][1];
}
}
}
int max=0;
for(int i=0; i<n; i++){
max = max < num[i][1] ? num[i][1] : max;
}
bw.write(max+"");
bw.flush();
}
}
'백준공부 > java' 카테고리의 다른 글
[백준] 2559번 수열 (silver 3 (0) | 2023.09.07 |
---|---|
[백준] 17952번 과제는 끝나지 않아! (silver 3 (0) | 2023.09.07 |
[백준] 2346번 풍선 터뜨리기 (silver 3 (0) | 2023.09.05 |
[백준] 13305번 주유소 문제 (silver 3 (0) | 2023.09.05 |
[백준] 1931번 회의실 배정 (silver 1 (0) | 2023.09.05 |