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 1581. Teamwork

[JAVA] Why is it wrong answer? My program works correctly on my computer.
Posted by icytwister 5 Jun 2012 16:59
import java.util.*;
public class timusTeam
{
    public static void main(String [] args)
    {
        int i=0;
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();

        if(n>1000 || n<1)
            return;

        int arr[]=new int[n];
        for(i=0;i<n;i++)
        {
            arr[i]=in.nextInt();
            if(arr[i]>10 || arr[i]<0)
                return;
        }

        int a;
        int sum=0;

        i=0;
        while(i<n)
        {
            a=arr[i];
            for(int k=0;k<n;k++)
                if(arr[k]==a)
                {
                    sum++;
                    i++;
                }
            System.out.print(sum +" " +a +" ");
            sum=0;
        }

    }
}

im frustrated :( Help me please

Edited by author 05.06.2012 16:59

Edited by author 05.06.2012 18:21
Re: [JAVA] Why is it wrong answer? My program works correctly on my computer.
Posted by Julius 26 Nov 2015 05:51
6
1 1 2 1 1 1
5 1 5 1 BUILD SUCCESSFUL (total time: 6 seconds)

answer ->
2 1 1 2 3 1 BUILD SUCCESSFUL (total time: 4 seconds)


You 're telling the amount of x number on the table, read again the problem, greetings.

Edited by author 26.11.2015 05:52