• 문제 링크
16406번: Exam
Your friend and you took the same true/false exam. You know your answers, your friend’s answers, and the number of your friend’s answers that were correct. Compute the maximum possible score you could have gotten
www.acmicpc.net
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int k = Integer.parseInt(br.readLine());
String a = br.readLine(), b = br.readLine();
int cnt = 0;
for (int i = 0; i < a.length(); i++) if (a.charAt(i) == b.charAt(i)) cnt++;
bw.write(String.valueOf(a.length() - Math.abs(k - cnt)));
bw.flush();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 30019 강의실 예약 시스템 - Greedy / Java (0) | 2023.12.23 |
---|---|
[백준] 11968 High Card Wins - Greedy / Java (0) | 2023.12.22 |
[백준] 20974 Even More Odd Photos - Greedy / Java (0) | 2023.12.20 |
[백준] 15761 Lemonade Line - Greedy / Java (0) | 2023.12.19 |
[백준] 28323 불안정한 수열 - Greedy / Java (0) | 2023.12.18 |
댓글