Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- int main(int argc, char const *argv[])
- {
- int n, A;
- scanf("%d %d",&n,&A);
- int *aux = (int*)malloc(sizeof(int)*1000001);
- int i,color;
- for(i=0;i<=1000001;i++)
- aux[i] = -1;
- int counter=0;
- for(i=1;i<=n;i++)
- {
- scanf("%d",&color);
- if(color==A) counter++;
- else {
- if(aux[color]>=counter-1){
- aux[color]++;
- }
- else{
- aux[color] = -2;
- }
- }
- }
- int ok=1;
- for(i=1;i<=1000001;i++){
- if(aux[i]>counter-1){
- printf("%d\n",i);
- ok=0;
- break;
- }
- }
- if(ok==1) printf("-1\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement