// File: /workspace/github_cpp_makefile_star2_O1/hcoona[P]POJ-Solutions/P1018.cpp
// Function: POJ::P1018::Solve(std::vector<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>, std::allocator<std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>>> const&) const
double P1018::Solve(const vector<vector<pair<int, int> > > &deviceData) const
    {
        map<int, int> bandwidthToPrice;
        for (auto it = deviceData.begin(); it != deviceData.end(); it++) {
            for (auto iit = it->begin(); iit != it->end(); iit++) {
                bandwidthToPrice[iit->first] = 0;
            }
        }

        const int INVALID_PRICE = -1;
        for (auto dit = deviceData.begin(); dit != deviceData.end(); dit++) {
            for (auto it = bandwidthToPrice.begin(); it != bandwidthToPrice.end(); it++) {
                if (it->second != INVALID_PRICE) {
                    auto beginPosition = dit->begin();
                    auto endPosition = upper_bound(
                        beginPosition,
                        dit->end(),
                        *it,
                        PredByFirstGt<int, int>);
                    if (beginPosition == endPosition) {
                        it->second = INVALID_PRICE;
                    } else {
                        it->second += min_element(beginPosition, endPosition, PredBySecondLt<int, int>)->second;
                    }
                }
            }
        }
        
        double maxBperP = 0.0;
        for (auto it = bandwidthToPrice.begin(); it != bandwidthToPrice.end(); it++) {
            auto BperP = static_cast<double>(it->first) / static_cast<double>(it->second);
            maxBperP = max(maxBperP, BperP);
        }
        return maxBperP;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rbx
leaq 0x18(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
movq (%rsi), %r13
movq 0x8(%rsi), %r15
cmpq %r15, %r13
je 0x1596
leaq 0x10(%rsp), %r14
movq (%r13), %r15
cmpq 0x8(%r13), %r15
je 0x1589
movq %r14, %rdi
movq %r15, %rsi
callq 0x17fe
movl $0x0, (%rax)
addq $0x8, %r15
jmp 0x156c
addq $0x18, %r13
movq 0x8(%rbx), %r15
cmpq %r15, %r13
jne 0x1568
movq (%rbx), %rbx
cmpq %r15, %rbx
je 0x1662
movq 0x28(%rsp), %r14
movq %r14, %rax
cmpq %r12, %r14
je 0x1655
movl 0x24(%rax), %ecx
cmpl $-0x1, %ecx
je 0x1644
movq (%rbx), %rdx
movq 0x8(%rbx), %rdi
subq %rdx, %rdi
sarq $0x3, %rdi
movq %rdx, %rsi
testq %rdi, %rdi
jle 0x1607
movl 0x20(%rax), %r8d
movq %rdx, %rsi
movq %rdi, %r9
shrq %r9
movq %r9, %r10
notq %r10
addq %rdi, %r10
leaq (%rsi,%r9,8), %rdi
addq $0x8, %rdi
cmpl -0x8(%rdi), %r8d
cmovleq %rdi, %rsi
cmovgq %r9, %r10
movq %r10, %rdi
testq %r10, %r10
jg 0x15dc
cmpq %rsi, %rdx
je 0x1633
leaq 0x8(%rdx), %rdi
cmpq %rsi, %rdi
je 0x163a
movl 0x4(%rdi), %r9d
movq %rdi, %r8
cmpl 0x4(%rdx), %r9d
jl 0x1625
movq %rdx, %r8
addq $0x8, %rdi
movq %r8, %rdx
cmpq %rsi, %rdi
jne 0x1615
jmp 0x163d
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x1641
movq %rdx, %r8
addl 0x4(%r8), %ecx
movl %ecx, 0x24(%rax)
movq %rax, %rdi
callq 0x10c0
cmpq %r12, %rax
jne 0x15b3
addq $0x18, %rbx
cmpq %r15, %rbx
jne 0x15a7
movq 0x28(%rsp), %rax
xorpd %xmm0, %xmm0
cmpq %r12, %rax
je 0x16a3
xorps %xmm2, %xmm2
cvtsi2sdl 0x20(%rax), %xmm2
xorps %xmm1, %xmm1
cvtsi2sdl 0x24(%rax), %xmm1
divsd %xmm1, %xmm2
maxsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movq %rax, %rdi
callq 0x10c0
movsd 0x8(%rsp), %xmm0
cmpq %r12, %rax
jne 0x1670
jmp 0x16a9
movsd %xmm0, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x187a
movsd 0x8(%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x187a
movq %rbx, %rdi
callq 0x1170