Submission #1177393

#TimeUsernameProblemLanguageResultExecution timeMemory
1177393vibhasExhibition (JOI19_ho_t2)Java
0 / 100
53 ms10616 KiB
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class joi2019_ho_t2 { public static void main(String[] args) throws Exception{ 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()); List<Picture> pictures = new ArrayList<>(); List<Integer> frames = new ArrayList<>(); for(int i = 0; i < n; i++){ st = new StringTokenizer(br.readLine()); int size = Integer.parseInt(st.nextToken()); int value = Integer.parseInt(st.nextToken()); pictures.add(new Picture(size, value)); } for(int i = 0; i < m; i++){ frames.add(Integer.parseInt(br.readLine())); } pictures.sort(new PictureComparator()); Collections.sort(frames); int first_sum = 0; int current_frame = 0; int current_picture = 0; while(current_frame < m && current_picture < n){ if(frames.get(current_frame) >= pictures.get(current_picture).size){ first_sum += 1; current_frame += 1; current_picture += 1; }else{ current_frame += 1; } } current_frame = 0; current_picture = 0; int second_sum = 0; while(current_frame < m && current_picture < n){ if(frames.get(current_frame) >= pictures.get(current_picture).size){ second_sum += 1; current_frame += 1; current_picture += 1; }else{ current_picture += 1; } } System.out.println(Math.max(first_sum, second_sum)); } } class Picture{ int value; int size; public Picture (int s, int v){ this.size = s; this.value = v; } } class PictureComparator implements Comparator<Picture> { public int compare(Picture pic1, Picture pic2) { if(pic1.value == pic2.value){ return pic1.size - pic2.size; }else{ return pic1.value - pic2.value; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...