fork download
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3. import java.util.stream.IntStream;
  4.  
  5. public class Ar2 {
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8. int[] votes = new int[sc.nextInt()];
  9. Arrays.fill(votes, 0);
  10. int M = sc.nextInt();
  11. for (int i = 0; i < M; i++) {
  12. votes[sc.nextInt()] += 1;
  13. }
  14. int maxVotes = Arrays.stream(votes).max().getAsInt();
  15. int candidate = 0;
  16. for (int maxCandidate : votes) {
  17. if (maxVotes == maxCandidate) {
  18. System.out.println(candidate);
  19. }
  20. candidate++;
  21. }
  22. }
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 4
1
2
3
3
compilation info
Main.java:5: error: class Ar2 is public, should be declared in a file named Ar2.java
public class Ar2 {
       ^
1 error
stdout
Standard output is empty