Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt();
- int[] values = new int[N];
- boolean[] probs = new boolean[N];
- for (int i = 0; i < N; i++) {
- values[i] = in.nextInt();
- probs[i] = false;
- }
- for(int i = 0; i < values.length; i++)
- if(p(values, values[i]) == values[i])
- probs[i] = true;
- int nb = 0;
- for(boolean b : probs)
- if(b)
- nb++;
- System.out.print(nb*100/N);
- }
- public static int p(int[] tab, int x)
- {
- int c = 0;
- for(int i : tab)
- if(i == x)
- c++;
- return c*100/tab.length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement