-
Notifications
You must be signed in to change notification settings - Fork 0
/
1792c.py
64 lines (47 loc) · 887 Bytes
/
1792c.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from bisect import bisect_right, bisect_left
"""
4
5
1 5 4 2 3
3
1 2 3
4
2 1 4 3
6
5 2 4 1 6 3
2
0
1
3
"""
"""
[1, 2, 4, 3, 5, 6]
[5, 1, 2, 3, 4, 6]
first and last need to be added last
"""
def solver(arr):
mid_pt = (len(arr) + 1) / 2
small = []
large = []
res = 0
for i in range(len(arr) // 2):
l = arr[i]
r = arr[len(arr) - 1 - l]
if l > mid_pt:
pass
elif not small or l > small[-1]:
small.append(l)
elif small:
index = bisect_right(small, l)
res = max(res, index)
small.insert(index, l)
if r < mid_pt:
pass
elif not large:
large.append()
t = int(input())
for i in range(t):
l = input()
arr = input().split(" ")
arr = [int(_) for _ in arr]
print(solver(arr))