답안 #125298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125298 2019-07-05T04:57:42 Z PizzaLovers007 Exhibition (JOI19_ho_t2) Java 11
100 / 100
978 ms 60656 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) -> {
            if (one.value == two.value)
            {
                return Long.compare(one.size, two.size);
            }
            return 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);


        // int count2 = bruteForce(pics, frames);
        // if (count != count2)
        // {
        //     out.println("-----WRONG ANSWER-----");
        // }

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

    public int bruteForce(Picture[] pics, long[] frames)
    {
        return 0;
    }

    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 228 ms 15844 KB Output is correct
2 Correct 218 ms 15012 KB Output is correct
3 Correct 217 ms 15492 KB Output is correct
4 Correct 218 ms 15412 KB Output is correct
5 Correct 208 ms 15648 KB Output is correct
6 Correct 218 ms 15536 KB Output is correct
7 Correct 210 ms 15060 KB Output is correct
8 Correct 209 ms 15128 KB Output is correct
9 Correct 207 ms 15528 KB Output is correct
10 Correct 211 ms 15188 KB Output is correct
11 Correct 205 ms 15656 KB Output is correct
12 Correct 212 ms 15372 KB Output is correct
13 Correct 215 ms 15360 KB Output is correct
14 Correct 211 ms 15488 KB Output is correct
15 Correct 211 ms 15188 KB Output is correct
16 Correct 213 ms 15592 KB Output is correct
17 Correct 215 ms 15308 KB Output is correct
18 Correct 209 ms 15000 KB Output is correct
19 Correct 220 ms 15228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 15844 KB Output is correct
2 Correct 218 ms 15012 KB Output is correct
3 Correct 217 ms 15492 KB Output is correct
4 Correct 218 ms 15412 KB Output is correct
5 Correct 208 ms 15648 KB Output is correct
6 Correct 218 ms 15536 KB Output is correct
7 Correct 210 ms 15060 KB Output is correct
8 Correct 209 ms 15128 KB Output is correct
9 Correct 207 ms 15528 KB Output is correct
10 Correct 211 ms 15188 KB Output is correct
11 Correct 205 ms 15656 KB Output is correct
12 Correct 212 ms 15372 KB Output is correct
13 Correct 215 ms 15360 KB Output is correct
14 Correct 211 ms 15488 KB Output is correct
15 Correct 211 ms 15188 KB Output is correct
16 Correct 213 ms 15592 KB Output is correct
17 Correct 215 ms 15308 KB Output is correct
18 Correct 209 ms 15000 KB Output is correct
19 Correct 220 ms 15228 KB Output is correct
20 Correct 275 ms 15804 KB Output is correct
21 Correct 274 ms 16444 KB Output is correct
22 Correct 270 ms 16344 KB Output is correct
23 Correct 280 ms 16464 KB Output is correct
24 Correct 291 ms 16548 KB Output is correct
25 Correct 240 ms 15676 KB Output is correct
26 Correct 282 ms 16376 KB Output is correct
27 Correct 277 ms 16252 KB Output is correct
28 Correct 290 ms 16368 KB Output is correct
29 Correct 291 ms 16292 KB Output is correct
30 Correct 290 ms 16584 KB Output is correct
31 Correct 282 ms 16620 KB Output is correct
32 Correct 253 ms 15868 KB Output is correct
33 Correct 249 ms 15520 KB Output is correct
34 Correct 268 ms 15932 KB Output is correct
35 Correct 230 ms 15924 KB Output is correct
36 Correct 273 ms 16292 KB Output is correct
37 Correct 291 ms 15872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 15844 KB Output is correct
2 Correct 218 ms 15012 KB Output is correct
3 Correct 217 ms 15492 KB Output is correct
4 Correct 218 ms 15412 KB Output is correct
5 Correct 208 ms 15648 KB Output is correct
6 Correct 218 ms 15536 KB Output is correct
7 Correct 210 ms 15060 KB Output is correct
8 Correct 209 ms 15128 KB Output is correct
9 Correct 207 ms 15528 KB Output is correct
10 Correct 211 ms 15188 KB Output is correct
11 Correct 205 ms 15656 KB Output is correct
12 Correct 212 ms 15372 KB Output is correct
13 Correct 215 ms 15360 KB Output is correct
14 Correct 211 ms 15488 KB Output is correct
15 Correct 211 ms 15188 KB Output is correct
16 Correct 213 ms 15592 KB Output is correct
17 Correct 215 ms 15308 KB Output is correct
18 Correct 209 ms 15000 KB Output is correct
19 Correct 220 ms 15228 KB Output is correct
20 Correct 275 ms 15804 KB Output is correct
21 Correct 274 ms 16444 KB Output is correct
22 Correct 270 ms 16344 KB Output is correct
23 Correct 280 ms 16464 KB Output is correct
24 Correct 291 ms 16548 KB Output is correct
25 Correct 240 ms 15676 KB Output is correct
26 Correct 282 ms 16376 KB Output is correct
27 Correct 277 ms 16252 KB Output is correct
28 Correct 290 ms 16368 KB Output is correct
29 Correct 291 ms 16292 KB Output is correct
30 Correct 290 ms 16584 KB Output is correct
31 Correct 282 ms 16620 KB Output is correct
32 Correct 253 ms 15868 KB Output is correct
33 Correct 249 ms 15520 KB Output is correct
34 Correct 268 ms 15932 KB Output is correct
35 Correct 230 ms 15924 KB Output is correct
36 Correct 273 ms 16292 KB Output is correct
37 Correct 291 ms 15872 KB Output is correct
38 Correct 796 ms 57752 KB Output is correct
39 Correct 762 ms 57884 KB Output is correct
40 Correct 705 ms 58064 KB Output is correct
41 Correct 961 ms 60424 KB Output is correct
42 Correct 864 ms 59372 KB Output is correct
43 Correct 814 ms 58216 KB Output is correct
44 Correct 862 ms 58212 KB Output is correct
45 Correct 801 ms 57888 KB Output is correct
46 Correct 823 ms 57896 KB Output is correct
47 Correct 808 ms 58632 KB Output is correct
48 Correct 903 ms 59136 KB Output is correct
49 Correct 751 ms 56480 KB Output is correct
50 Correct 714 ms 56412 KB Output is correct
51 Correct 908 ms 58152 KB Output is correct
52 Correct 901 ms 59156 KB Output is correct
53 Correct 887 ms 57732 KB Output is correct
54 Correct 849 ms 58544 KB Output is correct
55 Correct 818 ms 58040 KB Output is correct
56 Correct 745 ms 49704 KB Output is correct
57 Correct 536 ms 31084 KB Output is correct
58 Correct 663 ms 49144 KB Output is correct
59 Correct 802 ms 48948 KB Output is correct
60 Correct 479 ms 29896 KB Output is correct
61 Correct 742 ms 41488 KB Output is correct
62 Correct 819 ms 57968 KB Output is correct
63 Correct 905 ms 59904 KB Output is correct
64 Correct 803 ms 58660 KB Output is correct
65 Correct 978 ms 59708 KB Output is correct
66 Correct 884 ms 57516 KB Output is correct
67 Correct 902 ms 58432 KB Output is correct
68 Correct 900 ms 59624 KB Output is correct
69 Correct 811 ms 58120 KB Output is correct
70 Correct 812 ms 59120 KB Output is correct
71 Correct 893 ms 60656 KB Output is correct
72 Correct 761 ms 58068 KB Output is correct
73 Correct 795 ms 58364 KB Output is correct