SHARE
TWEET

Ranking

Edzhevit Nov 6th, 2018 146 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package AssociativeArraysExercise;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10.  
  11. public class Ranking {
  12.     public static void main(String[] args) throws IOException {
  13.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  14.  
  15.         String line = reader.readLine();
  16.  
  17.         Map<String, String> contestAndPassword = new HashMap<>();
  18.  
  19.         while (!line.equals("end of contests")){
  20.             String[] inputs = line.split(":");
  21.             String contest = inputs[0];
  22.             String password = inputs[1];
  23.             contestAndPassword.put(contest,password);
  24.  
  25.  
  26.             line = reader.readLine();
  27.         }
  28.  
  29.         String text = reader.readLine();
  30.  
  31.         Map<String, List<String>> submissions = new HashMap<>();
  32.  
  33.         while (!text.equals("end of submissions")){
  34.             String[] inputs = text.split("=>");
  35.             String contest2 = inputs[0];
  36.             String password2 = inputs[1];
  37.             String username = inputs[2];
  38.             int points = Integer.parseInt(inputs[3]);
  39.  
  40.             if (contestAndPassword.containsKey(contest2)
  41.                     && password2.equals(contestAndPassword.get(contest2))){
  42.                 submissions.put(username,new ArrayList<>());
  43.                 submissions.get(username).add(contest2);
  44.             }
  45.  
  46.             text = reader.readLine();
  47.         }
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top