Skip to content

Instantly share code, notes, and snippets.

@totynho
Created July 28, 2016 17:17
Show Gist options
  • Save totynho/e31f863a3bc47c5a6327a3fc6ed14a10 to your computer and use it in GitHub Desktop.
Save totynho/e31f863a3bc47c5a6327a3fc6ed14a10 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int N=1 , K=1;
while(N != 0 && K != 0){
N = entrada.nextInt();
K = entrada.nextInt();
while(N< 1 && N > 1000 && K < 1 && K > 100){
N = entrada.nextInt();
K = entrada.nextInt();
}
int P[] = new int[N];
for (int i = 0; i< N; i++){
P[i] = entrada.nextInt();
}
int check = 1;
int checkNumber = 0;
int alo = 0;
for (int i = 0; i< N; i++){
int lcheck = 0;
for (int j = 0; j< N; j++){
if (P[i] == P[j]){
lcheck++;
}
}
if (lcheck >= K){
check = lcheck;
if(checkNumber != P[i]){
checkNumber = P[i];
alo++;
}
}
}
if (N != 0){
System.out.println(alo);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment