AtCoder ABC 132 A&B&C AtCoder - 132
Since the bug of D combination cannot be removed, I will postpone it after D.
A - Fifty-Fifty
――If you count the characters, you must have two
private void solveA() {
String[] a = next().split("");
Map<String, Long> memo = Arrays.stream(a).collect(Collectors.groupingBy(s -> s, Collectors.counting()));
for (long elm : memo.values()) {
if (elm != 2) {
out.println("No");
return;
}
}
out.println("Yes");
}
B - Ordinary Number
-$ p_i $ is the second smallest of the three numbers $ p_ {i−1}, p_i, p_ {i + 1} $ --Since the above is satisfied, check $ p_ {i−1} <p_i <p_ {i + 1} $ or $ p_ {i + 1} <p_i <p_ {i−1} $.
private void solveB() {
int n = nextInt();
int[] p = IntStream.range(0, n).map(i -> nextInt()).toArray();
int res = 0;
for (int i = 0; i < p.length - 2; i++) {
if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i + 2] < p[i + 1] && p[i + 1] < p[i])) {
res++;
}
}
out.println(res);
}
C - Divide the Problems
--Sort --Extract the number of problem boundaries between ARC and ABC --The number of selectable differences in the number of boundaries
private void solveC() {
int n = nextInt();
int[] d = IntStream.range(0, n).map(i -> nextInt()).sorted().toArray();
out.println(d[n / 2] - d[n / 2 - 1]);
}
Recommended Posts