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

WA4 ...i don't understand!
Posted by Nextatix 21 Apr 2015 15:37
import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        Map<Integer, Integer> m = new TreeMap<Integer, Integer>();

        in.nextToken();
        int nv = 0;
        int count = (int)in.nval;

        for(int i=0; i<count; i++)
        {
            in.nextToken();
            nv = (int)in.nval;
            if(m.containsKey(nv)) m.put(nv,(int)(m.get(nv)+1));
            else m.put(nv, 1);
        }

        for(int i : m.keySet())
        {
            out.print(m.get(i));
            out.print(' ');
            out.print(i);
            out.print(' ');
        }

        out.flush();
    }
}