Thanks to visit codestin.com
Credit goes to github.com

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)