4
Restaurant(int id, int rating) {10
class RestaurantComparator implements Comparator<Restaurant> {12
public int compare(Restaurant r1, Restaurant r2) {13
return r1.rating == r2.rating ? r2.id - r1.id : r2.rating - r1.rating;18
public List<Integer> filterRestaurants(19
int[][] restaurants, int veganFriendly, int maxPrice, int maxDistance) {20
PriorityQueue<Restaurant> heap = new PriorityQueue<>(new RestaurantComparator());21
if (veganFriendly == 1) {22
for (int[] restaurant : restaurants) {23
if (restaurant[2] == 1 && restaurant[3] <= maxPrice && restaurant[4] <= maxDistance) {24
heap.offer(new Restaurant(restaurant[0], restaurant[1]));28
for (int[] restaurant : restaurants) {29
if (restaurant[3] <= maxPrice && restaurant[4] <= maxDistance) {30
heap.offer(new Restaurant(restaurant[0], restaurant[1]));34
List<Integer> answer = new ArrayList<>();35
while (!heap.isEmpty()) {36
answer.add(heap.poll().id);