Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
- Map<Integer, Integer> map = new LinkedHashMap<>();
- int index = 0;
- int reIn = 0;
- int max = 0;
- int n = sc.nextInt();
- for (int i = 0; i < n; i++) {
- map.put(sc.nextInt(), sc.nextInt());
- }
- for (int val : map.keySet()) {
- if (val > max && !(map.get(val) == 0)) {
- max = val;
- reIn = index;
- }
- index++;
- }
- if (!map.containsValue(1))
- System.out.println(-1);
- else System.out.println(reIn + 1);
- System.out.println(max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment