Skip to content

Commit 90f24f2

Browse files
committed
issue #44 11053
1 parent abed5c1 commit 90f24f2

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/backjoon/_11053.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package backjoon;
2+
// https://www.acmicpc.net/problem/11053
3+
4+
import java.io.BufferedReader;
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
7+
import java.util.StringTokenizer;
8+
9+
public class _11053 {
10+
public static void main(String[] args) throws IOException {
11+
12+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
13+
int N = Integer.parseInt(br.readLine());
14+
int[] seq = new int[N];
15+
Integer[] dp = new Integer[N];
16+
17+
StringTokenizer st = new StringTokenizer(br.readLine()," ");
18+
19+
for(int i = 0; i < N; i++) {
20+
seq[i] = Integer.parseInt(st.nextToken());
21+
}
22+
23+
for(int i = 0; i < N; i++) {
24+
dp[i] = 1;
25+
// 0 ~ i 이전 원소들 탐색
26+
for(int j = 0; j < i; j++) {
27+
if(seq[j] < seq[i] && dp[i] < dp[j] + 1) {
28+
dp[i] = dp[j] + 1; // j번째 원소의 +1 값이 i번째 dp가 된다.
29+
}
30+
}
31+
}
32+
33+
// 최대 길이 찾기
34+
int max = -1;
35+
for(int i = 0; i < N; i++) {
36+
max = dp[i] > max ? dp[i] : max;
37+
}
38+
System.out.println(max);
39+
}
40+
}
41+
/*
42+
input
43+
6
44+
10 20 10 30 20 50
45+
46+
output
47+
4
48+
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy