Submission #125293

#TimeUsernameProblemLanguageResultExecution timeMemory
125293PizzaLovers007Exhibition (JOI19_ho_t2)Java
0 / 100
222 ms16212 KiB
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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...