Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class kur {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Map<String, HashMap<String, List<Integer>>> judgeResults = new HashMap<>();
- String input;
- while (!"exam finished".equals(input = scanner.nextLine())) {
- String[] command = input.split("-");
- String name = command[0];
- String language = command[1];
- if ("banned".equals(language)) {
- for (Map.Entry<String, HashMap<String, List<Integer>>> wtf : judgeResults.entrySet()) {
- for (Map.Entry<String, List<Integer>> wow : wtf.getValue().entrySet()) {
- if (wow.getKey().equals(name)) {
- for (int i = 0; i < wow.getValue().size(); i++) {
- wow.getValue().set(i, 0);
- }
- }
- }
- }
- }else {
- int points = Integer.parseInt(command[2]);
- judgeResults.putIfAbsent(language, new HashMap<>());
- judgeResults.get(language).putIfAbsent(name, new ArrayList<>());
- judgeResults.get(language).get(name).add(points);
- for (Map.Entry<String, HashMap<String, List<Integer>>> wtf : judgeResults.entrySet()) {
- for (Map.Entry<String, List<Integer>> wow : wtf.getValue().entrySet()) {
- if (wow.getKey().equals(name)) {
- for (int i = 0; i < wow.getValue().size(); i++) {
- if (points > wow.getValue().get(i) && wow.getValue().get(i) != 0) {
- wow.getValue().set(i, 0);
- }else if (points < wow.getValue().get(i)) {
- wow.getValue().set(wow.getValue().indexOf(points), 0);
- }
- }
- }
- }
- }
- }
- }
- System.out.println("Results:");
- Map<String, List<Integer>> neznam = new HashMap<>();
- for (Map.Entry<String, HashMap<String, List<Integer>>> pak : judgeResults.entrySet()) {
- neznam.putAll(pak.getValue());
- }
- neznam.entrySet().stream().sorted((e2, e1) -> {
- int sort = Integer.compare(e1.getValue().stream().mapToInt(Integer::intValue).sum(),
- e2.getValue().stream().mapToInt(Integer::intValue).sum());
- if (sort == 0) {
- sort = e2.getKey().compareTo(e1.getKey());
- }
- return sort;
- }).forEach(e -> {
- System.out.print(e.getKey() + " | ");
- e.getValue().stream().filter(i -> i > 0).forEach(System.out::println);
- });
- // neznam.entrySet().stream().sorted((e1, e2) -> {
- // int sum1 = 0;
- // int sum2 = 0;
- // for (Map.Entry<String, List<Integer>> lul : e1.getValue().entrySet()) {
- // sum1 += lul.getValue().stream().mapToInt(Integer::intValue).sum();
- // }
- // for (Map.Entry<String, List<Integer>> lul : e2.getValue().entrySet()) {
- // sum2 += lul.getValue().stream().mapToInt(Integer::intValue).sum();
- // }
- // return Integer.compare(sum1, sum2);
- // })
- // .forEach(wtf -> {
- // for (Map.Entry<String, List<Integer>> omg : wtf.getValue().entrySet()) {
- // if (omg.getValue().stream().mapToInt(Integer::intValue).sum() > 0) {
- //
- // System.out.print(omg.getKey() + " ");
- // omg.getValue().stream().filter(e -> e > 0).forEach(System.out::println);
- // }
- // }
- // });
- System.out.println("Submissions:");
- judgeResults.entrySet().stream()
- .sorted((e2, e1) -> {
- int size1 = 0;
- for(Map.Entry<String, List<Integer>> wtf : e1.getValue().entrySet()) {
- size1 += wtf.getValue().size();
- }
- int size2 = 0;
- for(Map.Entry<String, List<Integer>> wtf : e2.getValue().entrySet()) {
- size2 += wtf.getValue().size();
- }
- int sort = Integer.compare(size1, size2);
- if (sort == 0) {
- sort = e1.getKey().compareTo(e2.getKey());
- }
- return sort;
- })
- .forEach(e -> {
- int size = 0;
- for(Map.Entry<String, List<Integer>> wtf : e.getValue().entrySet()) {
- size += wtf.getValue().size();
- }
- System.out.println(e.getKey() + " - " + size);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement