이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |