ABC解説

Toyota Programming Contest 2023 Spring Qual B(AtCoder Beginner Contest 290)

A. Contest Result

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    b = list(map(int, input().rstrip('\n').split()))
    print(sum([a[v-1] for v in b]))


if __name__ == '__main__':
    solve()

B. Qual B

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    s = list(str(input().rstrip('\n')))
    for i in range(n):
        if k == 0:
            s[i] = "x"
        else:
            if s[i] == "o":
                k -= 1
    print("".join(s))


if __name__ == '__main__':
    solve()

C. Max MEX

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * k
    for v in a:
        if v < k:
            ls[v] += 1
    for i in range(k):
        if ls[i] == 0:
            print(i)
            exit()
    print(k)


if __name__ == '__main__':
    solve()

-ABC解説