# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1127985 | secretwood01 | Exhibition (JOI19_ho_t2) | Java | 0 ms | 0 KiB |
import java.util.*;
import java.io.*;
class Pic implements Comparable<Pic> {
int s, v;
public Pic(int s, int v) {
this.s = s;
this.v = v;
}
public int compareTo(Pic p) {
if (v!=p.v) return Integer.compare(p.v, v);
else return Integer.compare(p.s, s);
}
}
public class Exhibition {
public static void main(String[] args) throws IOException {
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());
Pic [] p = new Pic[N];
for (int i=0;i<N;i++) {
st = new StringTokenizer(br.readLine());
p[i] = new Pic(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
}
int [] f = new int[M];
for (int i=0;i<M;i++) {
f[i] = Integer.parseInt(br.readLine());
}
br.close();
Arrays.sort(p);
for (Pic x : p) System.out.println(x.v + " " + x.s);
Arrays.sort(f);
int ans = 0;
int ind = M - 1;
for (int i=0;i<N;i++) {
if (p[i].s<=f[ind]) {
ans++;
ind--;
if (ind<0) break;
}
}
PrintWriter pw = new PrintWriter(System.out);
pw.println(ans);
pw.close();
}
}