Problem details
https://codeforces.com/contest/1956/problem/B
Problem - B - Codeforces
codeforces.com
Ideas
- You can only score points if you have two cards of the same number.
Answer code (Java)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t, n, a, ans;
boolean[] checkArr;
t = sc.nextInt();
for (int i = 0; i < t; i++) {
n = sc.nextInt();
ans = 0;
checkArr = new boolean[200000 + 1];
for (int j = 0; j < n; j++) {
a = sc.nextInt();
if (checkArr[a]) { // You can only score points if you have two cards of the same number.
ans++;
continue;
}
checkArr[a] = true;
}
System.out.println(ans);
}
}
}
'-- 기타 -- > Problem Solve' 카테고리의 다른 글
[백준 17287] The Deeper, The Better (0) | 2024.05.01 |
---|---|
[2024 KAKAO WINTER INTERNSHIP] 도넛과 막대 그래프 (0) | 2024.04.14 |
[2024 KAKAO WINTER INTERNSHIP] 가장 많이 받은 선물 (0) | 2024.04.14 |
[Codeforces Round 939] A. Nene's Game (0) | 2024.04.14 |
[Codeforces Round 938] B. Progressive Square (0) | 2024.04.14 |