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 1617. Flat Spots

Wrong answer in Java 1.7 test 4 please help me
Posted by Axmadjon 2 May 2014 19:33

import java.util.ArrayList;
import java.util.Scanner;

public class _1617 {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<Integer>();
        int n, i, count1 = 0, count2 = 0;

        n = s.nextInt();
        int[] res = new int[n];
        for (i = 0; i < n; i++) {
            res[i] = s.nextInt();
            list.add(res[i]);
        }

        int e = 0;
        for (i = 0; i < list.size(); i++) {
            if (list.get(e).equals(res[i])) {
                count1++;
                if (count1 == 4) {
                    count2++;
                }
            }
        }
        System.out.println(count2);
    }
}