728x90
6784번: Multiple Choice
The input will contain the number N (0 < N < 10000) followed by 2N lines. The 2N lines are composed of N lines of student responses (with one of A,B,C,D or E on each line), followed by N lines of correct answers (with one of A,B,C,D or E on each line), in
www.acmicpc.net
문제 풀이
처음 주어진 수만큼 리스트를 두 번 구성하는데, 두 리스트를 처음부터 순서대로 비교했을 때, 값이 같은 경우의 수를 구해준다.
최대 20000개의 문자가 들어올 수 있기 때문에 입력값을 받아주는 함수로 sys라이브러리의 readline을 활용했다.
정답 코드
import sys
input = sys.stdin.readline
lst = [input() for _ in range(int(input()))]
ans = 0
for i in range(len(lst)) :
if lst[i] == input() : ans += 1
print(ans)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6812 - Good times [python] (0) | 2023.03.19 |
---|---|
[BOJ/백준] 6794 - What is n, Daddy? [python] (0) | 2023.03.19 |
[BOJ/백준] 6780 - Sumac Sequences [python] (0) | 2023.03.19 |
[BOJ/백준] 6779 - Who Has Seen The Wind [python] (0) | 2023.03.19 |
[BOJ/백준] 6750 - Rotating letters [python] (0) | 2023.03.19 |