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 1880. Psych Up's Eigenvalues

My Accepted Solution in Java
Posted by Md johirul Islam 22 Jun 2015 19:26
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class T1880 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        List<Integer> an=new ArrayList<Integer>();
        List<Integer> bn=new ArrayList<Integer>();
        List<Integer> cn=new ArrayList<Integer>();
        int a=sc.nextInt();
        int count=0;
        int a1=a;
        while(a1-->0)
        {
            int n=sc.nextInt();
            an.add(n);
        }

        int b=sc.nextInt();
        int b1=b;
        while(b1-->0)
        {
            int n=sc.nextInt();
            bn.add(n);
        }

        int c=sc.nextInt();
        int c1=c;
        while(c1-->0)
        {
            int n=sc.nextInt();
            cn.add(n);
        }

        if(a>=b && a>=c)
        {
            for (Integer integer : an) {
                if(bn.contains(integer)&&cn.contains(integer))
                    count++;
            }
        }

        else if(b>=a && b>=c)
        {
            for (Integer integer : bn) {
                if(an.contains(integer)&&cn.contains(integer))
                    count++;
            }
        }
        else if(c>=b && c>=a)
        {
            for (Integer integer : cn) {
                if(bn.contains(integer)&&bn.contains(integer))
                    count++;
            }
        }

        System.out.println(count);

    }

}