Submission #39009966


Source Code Expand

#!/usr/bin/env python3
import math
import sys


sys.setrecursionlimit(10**8)

def isprime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0: return False
    return True


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    ans = 0
    for i in range(M) :
        ans += A[B[i]-1]
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A, B)

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task A - Contest Result
User jmwjmw
Language Python (3.8.2)
Score 100
Code Size 892 Byte
Status AC
Exec Time 23 ms
Memory 9064 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_max_00.txt, 03_min_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 17 ms 8976 KiB
00_sample_01.txt AC 17 ms 8968 KiB
00_sample_02.txt AC 17 ms 8892 KiB
01_random_00.txt AC 18 ms 9012 KiB
01_random_01.txt AC 18 ms 8972 KiB
01_random_02.txt AC 23 ms 8964 KiB
01_random_03.txt AC 19 ms 8864 KiB
01_random_04.txt AC 20 ms 8976 KiB
01_random_05.txt AC 20 ms 9012 KiB
01_random_06.txt AC 20 ms 9052 KiB
01_random_07.txt AC 18 ms 9036 KiB
01_random_08.txt AC 18 ms 8900 KiB
01_random_09.txt AC 19 ms 8936 KiB
02_max_00.txt AC 19 ms 8940 KiB
03_min_00.txt AC 19 ms 9064 KiB