knightnemo commited on
Commit
c67e509
·
verified ·
1 Parent(s): 7491096

Upload code_segments/segment_159.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_159.txt +21 -0
code_segments/segment_159.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Tim is doing a test consisting of $4n$ questions; each question has $4$ options: 'A', 'B', 'C', and 'D'. For each option, there are exactly $n$ correct answers corresponding to that option — meaning there are $n$ questions with the answer 'A', $n$ questions with the answer 'B', $n$ questions with the answer 'C', and $n$ questions with the answer 'D'.
2
+
3
+ For each question, Tim wrote his answer on the answer sheet. If he could not figure out the answer, he would leave a question mark '?' for that question.
4
+
5
+ You are given his answer sheet of $4n$ characters. What is the maximum number of correct answers Tim can get?
6
+
7
+ The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
8
+
9
+ The first line of each test case contains an integer $n$ ($1 \le n \le 100$).
10
+
11
+ The second line of each test case contains a string $s$ of $4n$ characters ($s_i \in \\{\texttt{A}, \texttt{B}, \texttt{C}, \texttt{D}, \texttt{?}\\}$) — Tim's answers for the questions.
12
+
13
+ For each test case, print a single integer — the maximum score that Tim can achieve.
14
+
15
+ In the first test case, there is exactly one question with each answer 'A', 'B', 'C', and 'D'; so it's possible that Tim gets all his answers correct.
16
+
17
+ In the second test case, there are only two correct answers 'A' which makes him get exactly $2$ points in any case.
18
+
19
+ In the third test case, Tim can get at most $2$ correct answers with option 'A' and $2$ correct answers with option 'B'. For example, he would get $4$ points if the answers were 'AACCBBDD'.
20
+
21
+ In the fourth test case, he refuses to answer any question at all, which makes him get $0$ points.