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

Why WA?
Posted by Georgeek 6 Jul 2011 12:15
import java.util.Arrays;
import java.util.Scanner;


public class Example2 {

    private static int[] col;
    private static int count = 1;
    private static int superCount = 0;

    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(System.in);
            int a = scanner.nextInt();
            if (a>=0 && a<=150){
                col = new int[a];
                for (int i = 0; i < a; i++) {
                    col[i]=scanner.nextInt();
                    if(col[i]<600 || col[i]>700){
                        //System.out.print("0");
                        throw new Exception();
                    }
                }
                Arrays.sort(col);
                for (int i = 1; i < col.length; i++) {
                    if (col[i]==col[i-1]) {
                        count ++;
                        if (count==4) {
                            superCount ++;
                            count=1;
                        }
                    }else count=1;
                }
                System.out.print(superCount);
            }else if (a>=0){System.out.print("0");}
        } catch (Exception e) {}
    }

}