Language: Java

import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;
import java.io.PrintWriter;
import java.util.Collections;

public class Main { //クラス名はMain
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      PrintWriter out = new PrintWriter(System.out);
      String[] paras = sc.next().split(" ");
      int n = Integer.parseInt(paras[0]);
      int m = Integer.parseInt(paras[1]);
      Map<Integer,List<Integer>> map = new HashMap<>();
      for(int i = 0;i<n;i++){
        String[] reward = sc.next().split(" ");
        int day = Integer.parseInt(reward[0]);
        int num = Integer.parseInt(reward[1]);
        if(day > m) continue;
        if(map.containsKey(day)){
          List<Integer> l = map.get(day);
          l.add(num);
          map.put(day,l);
        }else{
          List<Integer> l = new ArrayList<>();
          l.add(num);
          map.put(day,l);
        }
      }
      
      int[] taken = new int[m+1];
      for(int i = m;i>=1;i--){
        if(map.containsKey(i)){
          List<Integer> l = map.get(i);
          Collections.sort(l,Comparator.reverseOrder());
          map.put(i,l);
        }else taken[i] = -1;
      }
      
      long ans = 0;
      for(int i = m;i>=1;i--){
        int max = 0;
        int last = 0;
        for(j = i;j<=m;j++){
          if(taken[i] < 0) continue;
          List<Integer> l = map.get(j);
          if(taken[i] >=l.size()) continue;
          if(l.get(taken[i]) > max){
            max = taken[i];
            taken[last]--;
            taken[i]++;
            last = i;
          }
        }
        ans += max;
      }
      
      out.println(ans);
      out.flush();
    }
}


Compiler output:
Main.java:14: error: cannot find symbol
      Map<Integer,List<Integer>> map = new HashMap<>();
                  ^
  symbol:   class List
  location: class Main
Main.java:21: error: cannot find symbol
          List<Integer> l = map.get(day);
          ^
  symbol:   class List
  location: class Main
Main.java:25: error: cannot find symbol
          List<Integer> l = new ArrayList<>();
          ^
  symbol:   class List
  location: class Main
Main.java:25: error: cannot find symbol
          List<Integer> l = new ArrayList<>();
                                ^
  symbol:   class ArrayList
  location: class Main
Main.java:34: error: cannot find symbol
          List<Integer> l = map.get(i);
          ^
  symbol:   class List
  location: class Main
Main.java:35: error: cannot find symbol
          Collections.sort(l,Comparator.reverseOrder());
                             ^
  symbol:   variable Comparator
  location: class Main
Main.java:44: error: cannot find symbol
        for(j = i;j<=m;j++){
            ^
  symbol:   variable j
  location: class Main
Main.java:44: error: cannot find symbol
        for(j = i;j<=m;j++){
                  ^
  symbol:   variable j
  location: class Main
Main.java:44: error: cannot find symbol
        for(j = i;j<=m;j++){
                       ^
  symbol:   variable j
  location: class Main
Main.java:46: error: cannot find symbol
          List<Integer> l = map.get(j);
          ^
  symbol:   class List
  location: class Main
Main.java:46: error: cannot find symbol
          List<Integer> l = map.get(j);
                                    ^
  symbol:   variable j
  location: class Main
11 errors