답안 #125293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125293 2019-07-05T04:53:38 Z PizzaLovers007 Exhibition (JOI19_ho_t2) Java 11
0 / 100
222 ms 16212 KB
import java.io.*;
import java.util.*;

public class joi2019_ho_t2
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(tok.nextToken());
        int m = Integer.parseInt(tok.nextToken());
        Picture[] pics = new Picture[n];
        for (int i = 0; i < n; i++)
        {
            tok = new StringTokenizer(in.readLine());
            long size = Long.parseLong(tok.nextToken());
            long value = Long.parseLong(tok.nextToken());
            pics[i] = new Picture(size, value);
        }
        long[] frames = new long[m];
        for (int i = 0; i < m; i++)
        {
            tok = new StringTokenizer(in.readLine());
            frames[i] = Long.parseLong(tok.nextToken());
        }
        Arrays.sort(frames);
        Arrays.sort(pics, (one, two) -> Long.compare(one.value, two.value));

        int count = 0;
        int currPic = n-1;
        for (int i = m-1; i >= 0; i--)
        {
            while (currPic >= 0 && pics[currPic].size > frames[i])
            {
                currPic--;
            }
            if (currPic >= 0)
            {
                count++;
                currPic--;
            }
        }
        out.println(count);

        out.flush();
        in.close();
    }

    public static void main(String[] args) throws IOException
    {
        new joi2019_ho_t2().go();
    }

    private static class Picture
    {
        long size, value;

        public Picture(long s, long v)
        {
            size = s;
            value = v;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 219 ms 16212 KB Output is correct
2 Correct 222 ms 15488 KB Output is correct
3 Incorrect 221 ms 15464 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 219 ms 16212 KB Output is correct
2 Correct 222 ms 15488 KB Output is correct
3 Incorrect 221 ms 15464 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 219 ms 16212 KB Output is correct
2 Correct 222 ms 15488 KB Output is correct
3 Incorrect 221 ms 15464 KB Output isn't correct
4 Halted 0 ms 0 KB -