practivceAlgorithm/swexpertacademy

[SWEA][Python] 5122 수열편집

findTheValue 2021. 8. 24. 00:39

삽입, 삭제, 변경

 

for test in range(1,int(input())+1):
    N, M, L = map(int, input().split())
    arr = list(map(int, input().split()))
    flag = 1
    for _ in range(M):
        command = input().split()
        if command[0] == 'I':
            arr.insert(int(command[1]),int(command[2]))
        elif command[0] == 'D':
            if not arr:
                flag=0
                break
            arr.pop(int(command[1]))
        else:
            arr[int(command[1])] = int(command[2])
    if len(arr) > L:
        if flag:
            print(f'#{test} {arr[L]}')
        else:
            print(f'#{test} -1')
    else:
        print(f'#{test} -1')

'practivceAlgorithm > swexpertacademy' 카테고리의 다른 글

[SWEA][Python] 5176 이진 탐색  (0) 2021.08.24
[SWEA][Python] 5174 subtree  (0) 2021.08.24
[SWEA][Python] 5120 암호  (0) 2021.08.24
[SWEA][Python] 5110 수열 합치기  (0) 2021.08.24
[SWEA][Python] 5108 숫자추가  (0) 2021.08.24