File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ //https://www.acmicpc.net/problem/11568
2+ import java .io .BufferedReader ;
3+ import java .io .IOException ;
4+ import java .io .InputStreamReader ;
5+ import java .util .StringTokenizer ;
6+
7+ public class BOJ_S2_11568_민균이의계략 {
8+ public static void main (String [] args ) throws IOException {
9+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
10+
11+ int N = Integer .parseInt (br .readLine ());
12+ int [] nums = new int [N ];
13+ int [] dp = new int [N ];
14+
15+ StringTokenizer st = new StringTokenizer (br .readLine ());
16+ for (int i = 0 ; i < N ; i ++) {
17+ nums [i ] = Integer .parseInt (st .nextToken ());
18+ dp [i ] = 1 ;
19+ }
20+
21+ for (int i = 1 ; i < N ; i ++) {
22+ for (int j = 0 ; j < i ; j ++) {
23+ if (nums [i ] > nums [j ]){
24+ dp [i ] = Math .max (dp [i ], dp [j ] + 1 );
25+ }
26+ }
27+ }
28+
29+ int max = 1 ;
30+
31+ for (int i = 0 ; i < N ; i ++) {
32+ max = Math .max (max , dp [i ]);
33+ }
34+
35+ System .out .println (max );
36+
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments