-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
from typing import List | ||
|
||
|
||
def solve(): | ||
N = int(sys.stdin.readline().strip()) | ||
dts: List[int] = [0] + list(map(int, sys.stdin.readline().strip().split(' '))) | ||
dp: List[int] = [0 for _ in range(N + 1)] | ||
answer = 0 | ||
|
||
for idx in range(1, N + 1): | ||
mx = 0 | ||
for i2 in range(idx + 1): | ||
if dts[i2] < dts[idx]: | ||
mx = max(mx, dp[i2]) | ||
|
||
dp[idx] = mx + 1 | ||
answer = max(answer, dp[idx]) | ||
|
||
print(answer) | ||
|
||
|
||
if __name__ == '__main__': | ||
solve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
6 | ||
10 20 10 30 20 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sys | ||
from pathlib import Path | ||
from unittest import TestCase | ||
from main import solve | ||
|
||
|
||
class Test(TestCase): | ||
def my_solve(self, testcase_input): | ||
sys.stdin = open(testcase_input, 'r') | ||
stdout = sys.stdout | ||
sys.stdout = open('stdout.txt', 'w') | ||
solve() | ||
sys.stdout.close() | ||
sys.stdout = stdout | ||
|
||
def test_solve(self, testcase_number: str): | ||
self.my_solve('test' + testcase_number + '.txt') | ||
self.assertEqual( | ||
Path('test' + testcase_number + '_answer.txt').read_text().strip(), | ||
Path('stdout.txt').read_text().strip()) | ||
|
||
def test1_solve(self): | ||
self.test_solve('1') |