var n int var a, b [N]int var in = bufio.NewReader(os.Stdin)
funcmain() { fmt.Fscan(in, &n) for i := 1; i <= n; i++ { fmt.Fscan(in, &a[i], &b[i]) } l, r := 1, int(1e9) for { if l >= r { break } mid := (l + r) / 2 t := check(mid) if t == 1 || t == 3 { r = mid } else { l = mid + 1 } } fmt.Printf("%d ", l) l, r = 1, int(1e9) for { if l >= r { break } mid := (l + r + 1) / 2 t := check(mid) if t == 1 || t == 2 { l = mid } else { r = mid - 1 } } fmt.Printf("%d", l) }
funccheck(x int)int { for i := 1; i <= n; i++ { t := a[i] / x if t > b[i] { return2 } if t < b[i] { return3 } } return1 }