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

time limit ex... WA test 7, Why???
Posted by Garik 12 Oct 2014 03:56
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

public class Timus{
    public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        ArrayList<Integer> arr = new ArrayList<Integer>();
        int n = in.nextInt();
        for (int i = 0; i< n; ++i){
            arr.add(in.nextInt());
        }
        int b = in.nextInt();
        for (int i = 0; i< b; ++i){
            arr.add(in.nextInt());
        }
        b = in.nextInt();
        for (int i = 0; i< b; ++i){
            arr.add(in.nextInt());
        }
        int sum=0;
        int occurrences = 0;
        for(int j =0; j<n; ++j){
            occurrences = Collections.frequency(arr, arr.get(j));
            if (occurrences % 3 == 0){
                sum = sum + occurrences;
            }
        }

        System.out.print(sum/3);


    }
}