Skip to content

1770

A_Koxia_and_Whiteboards

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def solve():
    n, m = map(int, input().split())

    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    for i in range(m):
        a.sort(reverse=True)
        a = a[: n - 1] + [b[i]]
    print(sum(a))


for _ in range(int(input())):
    solve()

B_Koxia_and_Permutation

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def solve():
    n, _ = map(int, input().split())

    res = []
    a = [i + 1 for i in range(n // 2)]
    b = [i for i in range(n, n // 2, -1)]

    for i in range(n // 2):
        res.append(b[i])
        res.append(a[i])
    if n % 2:
        res.append(b[-1])
    print(*res)


for _ in range(int(input())):
    solve()