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 1025. Democracy in Danger

Why WA?
Posted by Georgeek 30 Jun 2011 15:53
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;


public class DemocracyInDanger {

    private static int sum = 0;
    private static int i=0;

    public static void main(String[] args) {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            int amount = Integer.parseInt(in.readLine());
            if(amount>=1 && amount<=101 && amount%2!=0){
                int[] party = new int[amount];
                Scanner scanner = new Scanner(System.in);
                while(i<amount){
                    party[i]=scanner.nextInt();
                    if(party[i]>0 && party[i]%2!=0){
                        sum+=party[i];
                    }else    throw new IOException();
                    i++;
                }
                if (sum<=9999){
                    sum=0;
                    Arrays.sort(party);
                    for (int i = 0; i <=amount/2; i++) {
                        sum +=party[i]/2+1;
                    }
                    System.out.println(sum);
                }
            }

        } catch (Exception e) {
        }
    }

}