ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1510. Order

WA#12
Posted by Frenzyk 1 Dec 2017 17:05
#include <stdio.h>

int main(){
int i,n,x,y,z,x1=0,y1=0,z1=0;
scanf("%d",&n);
int* A=new int[n];
for(i=0;i<n;i++)
scanf("%d",&A[i]);
x=A[0];
i=1;
y=-100;
while(1){
if(A[i]==x)
x=A[i];
else if(A[i]!=y)
y=A[i];
else
{
z=A[i];
break;
}
i++;}
for(i=0;i<n;i++)
{
if(A[i]==x)
x1++;
else if(A[i]==y)
y1++;
else if(A[i]==z)
z1++;
}
if(x1>y1 && x1>z1)
printf("%d",x);
else if (y1>z1 && y1>x1)
printf("%d",y);
else if (z1>x1 && z1>y1)
printf ("%d",z);
return 0;
}