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 crash is happening
Posted by Paul 6 Nov 2012 20:36
this is my code and its wrking fine on my pc



import java.io.*;
import java.util.Scanner;

public class Democracy {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner sc = new Scanner (System.in);
        System.out.println("enter no of groups");
        int n = sc.nextInt();

        System.out.println("enter group members");
        //String s = sc.next();
        //String[] num = s.split(",");
        String[] num = sc.next().split(",");


        int[] num1 = new int[num.length];
        int x =0;
        for(String a: num){
            num1[x] = Integer.parseInt(a);
            //System.out.println(a);
            x++;
        }

        int len = n/2+1;
        int[] min = new int[len];



            for(int i = 0; i <len; i++ ){
                min[i] = num1[i];
                for(int j= i+1; j<num1.length; j++ ){
                    if(min[i] > num1[j]){
                        min[i] = num1[j];
                    }
                }
            }

        int vote = 0;
        for(int i =0; i<len; i++){
            vote = vote+  min[i]/2+1;
        }


        System.out.println(vote);


    }

}