//for jasnah
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int T = scanner.nextInt();
if (T > 3 || T <= 0) {
return;
}
while (T-- > 0) {
int N = scanner.nextInt();
if (N > 300000 || N <= 0) {
return;
}
long[] heights = new long[N];
long max_height = 0;
long count_max_height = 0;
for (int i = 0; i < N; i++) {
long m = scanner.nextLong();
if (m < 0 || m > 1000000) {
return;
}
heights[i] = m;
max_height = Math.max(max_height, heights[i]);
}
for (int i = 0; i < N; i++) {
if (heights[i] == max_height) {
count_max_height++;
}
}
if (count_max_height % 2 == 1 && max_height != 0) {
System.out.println(count_max_height);
} else {
System.out.println(0);
}
}
}
}
But every time I fail the last test no matter what I do.
created
last reply
- 4
replies
- 333
views
- 2
users
- 1
like
- 1
link