Submission #1179450

#TimeUsernameProblemLanguageResultExecution timeMemory
1179450vibhasExhibition (JOI19_ho_t2)Java
Compilation error
0 ms0 KiB
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class JOI_19_exhibition{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int[][]already_calculated = new int[n][m];
        Map<List<Integer>, Integer>memoi = new HashMap<>();
        Picture[] pictures = new Picture[n];
        int[] frames = new int[m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                already_calculated[i][j] = -1;
            }
        }
        for(int i = 0; i < n; i++){
            st = new StringTokenizer(br.readLine());
            pictures[i] = new Picture(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
        }
        for(int i = 0; i < m; i++){
            frames[i] = Integer.parseInt(br.readLine());
        }
        Arrays.sort(pictures, new PictureComp());
        Arrays.sort(frames);
        System.out.println(recursive(0, 0, pictures, frames, memoi));
    }
    public static int recursive(int picture_index, int frame_index, Picture[] pic, int[]fra, Map<List<Integer>, Integer> memoi) {
        if ((picture_index >= pic.length) || (frame_index >= fra.length)) {
            return 0;
        }
        List<Integer> ordered_pair = new ArrayList<>();
        ordered_pair.add(picture_index);
        ordered_pair.add(frame_index);
        if(memoi.containsKey(ordered_pair) && !(memoi.get(ordered_pair) == -1)){
            return memoi.get(ordered_pair);
        }
        if(fra[frame_index] >= pic[picture_index].size){
            // choosing both frame and picture and moving the pointers.
            memoi.put(ordered_pair,1 + recursive(picture_index + 1, frame_index + 1, pic, fra, memoi));
            return memoi.get(ordered_pair);
        }else {
            // move to the next indices on either and see which is better.
            int second_ans = Math.max(recursive(picture_index +1, frame_index, pic, fra, memoi), recursive(picture_index, frame_index + 1, pic, fra, memoi));
            memoi.put(ordered_pair, second_ans);
            return memoi.get(ordered_pair);
        }
    }
}
class Picture{
    int size;
    int value;
    public Picture(int a, int b){
        this.size = a;
        this.value = b;
    }
}
class PictureComp implements Comparator<Picture> {
    public int compare(Picture p1, Picture p2){
        if(p1.value == p2.value){
            return p1.size - p2.size;
        }
        return p1.value-p2.value;
    }
}

Compilation message (stderr)

joi2019_ho_t2.java:5: error: class JOI_19_exhibition is public, should be declared in a file named JOI_19_exhibition.java
public class JOI_19_exhibition{
       ^
1 error

=======