Language: C++

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1000000007;
const long double big=1e8+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T>
pair<llint,deque<T>> tensort(const deque<T>& in,int hi,int mg){//転倒数を計算しながらソートします
	if(hi+1==mg){
		deque<lldo>iti;
		iti.pub(in[hi]);
		return mp((llint)0,iti);
	}
	int mid=(hi+mg)/2;
	auto hso=tensort(in,hi,mid);
	auto mso=tensort(in,mid,mg);
	llint ans=hso.fir+mso.fir;
	deque<T>iti;
	while(hso.sec.size()!=0||mso.sec.size()!=0){
		if(hso.sec.empty()){iti.pub(mso.sec.front());mso.sec.pof();}
		else if(mso.sec.empty()){iti.pub(hso.sec.front());hso.sec.pof();}
		else if(hso.sec.front()<mso.sec.front()){iti.pub(hso.sec.front());hso.sec.pof();}
		else{iti.pub(mso.sec.front());mso.sec.pof();ans+=hso.sec.size();}
	}
	return mp(ans,iti);
}
lldo solve(vector<tuple<int,int,int>> a){
	int n,i;n=a.size();
	vector<tuple<lldo,lldo,int>>car(n);//y=ax+b
	for(i=0;i<n;i++){
		get<0>(car[i])=(lldo)-get<0>(a[i])/(lldo)get<1>(a[i]);
		get<1>(car[i])=(lldo)get<2>(a[i])/(lldo)get<1>(a[i]);
		get<2>(car[i])=i;
	}
	sort(car.begin(),car.end());//xを無限大に飛ばしたときの車の配置
	lldo bmax=big,bmin=-big;
	llint beet;
	for(int q=0;q<50;q++){
		lldo gen=(bmax+bmin)/2;
		deque<lldo> ima(n);
		for(i=0;i<n;i++){ima[i]=get<0>(car[i])*gen+get<1>(car[i]);}
		auto pa=tensort(ima,0,n);
		beet=pa.fir;
		if(beet<=(n*(n-1)/4)){bmax=gen;}
		else{bmin=gen;}
	}
	deque<pair<lldo,int>>ima(n);
	for(i=0;i<n;i++){
		ima[i].fir=get<0>(car[i])*bmin+get<1>(car[i]);
		ima[i].sec=get<2>(car[i]);
	}//少し大きく
	sort(ima.begin(),ima.end());
	lldo nex=big;
	for(i=0;i<n-1;i++){
		mineq(nex,(ima[i].fir-ima[i+1].fir)/(a[ima[i].sec]-a[ima[i+1].sec]));
	}
	return nex;
}
int main(void){
	ios::sync_with_stdio(false);
	int n,i;
	cin>>n;
	vector<tuple<int,int,int>>a(n);
	for(i=0;i<n;i++){cin>>get<0>(a[i])>>get<1>(a[i])>>get<2>(a[i]);}
	cout<<setprecision(20)<<solve(a);
	for(i=0;i<n;i++){swap(get<0>(a[i]),get<1>(a[i]));}
	cout<<" "<<solve(a)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'lldo solve(std::vector<std::tuple<int, int, int> >)':
a.cc:92:67: error: no match for 'operator-' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'std::tuple<int, int, int>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'std::tuple<int, int, int>'})
   92 |                 mineq(nex,(ima[i].fir-ima[i+1].fir)/(a[ima[i].sec]-a[ima[i+1].sec]));
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/deque:62,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:92:82: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'std::tuple<int, int, int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
   92 |                 mineq(nex,(ima[i].fir-ima[i+1].fir)/(a[ima[i].sec]-a[ima[i+1].sec]));
      |                                                                                  ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:92:82: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'std::tuple<int, int, int>'} is not derived from 'const std::move_iterator<_IteratorL>'
   92 |                 mineq(nex,(ima[i].fir-ima[i+1].fir)/(a[ima[i].sec]-a[ima[i+1].sec]));
      |                                                                                  ^