Sign errors: If you want minimum and slopes are increasing, you need the upper envelope, not lower. Double-check your setup.
Wrong domination check: The intersection formula can have division issues. Use cross-multiplication to avoid floating point.
Forgetting the extra term: Remember to add back or whatever you factored out.
Overflow: can overflow 64-bit integers. Use 128-bit or __int128 if needed.
Off-by-one: Process lines before querying. Don't query with a line you haven't added yet.