File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed
백준 11053번 가장 긴 증가하는 부분 수열 Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+ from typing import List
3
+
4
+
5
+ def solve ():
6
+ N = int (sys .stdin .readline ().strip ())
7
+ dts : List [int ] = [0 ] + list (map (int , sys .stdin .readline ().strip ().split (' ' )))
8
+ dp : List [int ] = [0 for _ in range (N + 1 )]
9
+ answer = 0
10
+
11
+ for idx in range (1 , N + 1 ):
12
+ mx = 0
13
+ for i2 in range (idx + 1 ):
14
+ if dts [i2 ] < dts [idx ]:
15
+ mx = max (mx , dp [i2 ])
16
+
17
+ dp [idx ] = mx + 1
18
+ answer = max (answer , dp [idx ])
19
+
20
+ print (answer )
21
+
22
+
23
+ if __name__ == '__main__' :
24
+ solve ()
Original file line number Diff line number Diff line change
1
+ 6
2
+ 10 20 10 30 20 50
Original file line number Diff line number Diff line change
1
+ 4
Original file line number Diff line number Diff line change
1
+ import sys
2
+ from pathlib import Path
3
+ from unittest import TestCase
4
+ from main import solve
5
+
6
+
7
+ class Test (TestCase ):
8
+ def my_solve (self , testcase_input ):
9
+ sys .stdin = open (testcase_input , 'r' )
10
+ stdout = sys .stdout
11
+ sys .stdout = open ('stdout.txt' , 'w' )
12
+ solve ()
13
+ sys .stdout .close ()
14
+ sys .stdout = stdout
15
+
16
+ def test_solve (self , testcase_number : str ):
17
+ self .my_solve ('test' + testcase_number + '.txt' )
18
+ self .assertEqual (
19
+ Path ('test' + testcase_number + '_answer.txt' ).read_text ().strip (),
20
+ Path ('stdout.txt' ).read_text ().strip ())
21
+
22
+ def test1_solve (self ):
23
+ self .test_solve ('1' )
You can’t perform that action at this time.
0 commit comments