Language: C++

#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

bool besarDulu(const int &a, const int &b)
{
    return a > b;
}

bool tupleSort1(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
    return get<2>(a) > get<2>(b);
}

bool tupleSort2(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    if (get<3>(a) == get<3>(b)) return get<2>(a) < get<2>(b);
    return get<3>(a) < get<3>(b);
}

bool pairSortFirst(pair<int, int> &a, pair<int, int> &b)
{
    if (a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

bool pairSortSecond(pair<int, int> &a, pair<int, int> &b)
{
    if (a.second == b.second) return a.first < b.first;
    return a.second < b.second;
}

using ll = long long int;
const int MAX = 1000000000;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, T;
    cin >> N >> T;
    ll time = 1;
    vector<tuple<int, int, int>> shop, shop2;
    map<int, bool> visited;
    int aPoint = 0, bPoint = 0;
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        shop.push_back({i, a, b});
        shop2.push_back({i, a, b});
    }
    sort(shop.begin(), shop.end(), tupleSort1);
    sort(shop2.begin(), shop2.end(), tupleSort2);
    int i;
    for (i = 0; i < N; i++)
    {
        while (visited[aPoint])
        {
            aPoint++;
        }
        while (visited[bPoint])
        {
            bPoint++;
        }
        int a = (time * get<1>(shop[aPoint])) + get<2>(shop[aPoint]);
        int b = (time * get<1>(shop[bPoint])) + get<2>(shop[bPoint]);
        if (min(a, b) < T) break;
        time += min(a, b);
    }

    cout << time << '\n';
    return 0;
}

/*
3 7 = 7.5
travel = 1 = 1
store 1 = 1 x 2 + (0) = 2
travel = 1 = 3
store 3 = 3 x 0 + 3 = 6 

*/

Compiler output:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/tuple: In instantiation of 'struct std::tuple_element<3, std::tuple<int, int, int> >':
/usr/include/c++/14/bits/utility.h:84:11:   required by substitution of 'template<long unsigned int __i, class _Tp> using std::__tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 3; _Tp = std::tuple<int, int, int>]'
   84 |     using __tuple_element_t = typename tuple_element<__i, _Tp>::type;
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2466:5:   required by substitution of 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&) [with long unsigned int __i = 3; _Elements = {int, int, int}]'
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
a.cc:17:46:   required from here
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                        ~~~~~~^~~
/usr/include/c++/14/tuple:2422:25: error: static assertion failed: tuple index must be in range
 2422 |       static_assert(__i < sizeof...(_Types), "tuple index must be in range");
      |                     ~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2422:25: note: the comparison reduces to '(3 < 3)'
In file included from /usr/include/c++/14/bits/stl_pair.h:62,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/utility.h: In instantiation of 'struct std::_Nth_type<3, int, int, int>':
/usr/include/c++/14/tuple:2424:13:   required from 'struct std::tuple_element<3, std::tuple<int, int, int> >'
 2424 |       using type = typename _Nth_type<__i, _Types...>::type;
      |             ^~~~
/usr/include/c++/14/bits/utility.h:84:11:   required by substitution of 'template<long unsigned int __i, class _Tp> using std::__tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 3; _Tp = std::tuple<int, int, int>]'
   84 |     using __tuple_element_t = typename tuple_element<__i, _Tp>::type;
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2466:5:   required by substitution of 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&) [with long unsigned int __i = 3; _Elements = {int, int, int}]'
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
a.cc:17:46:   required from here
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                        ~~~~~~^~~
/usr/include/c++/14/bits/utility.h:237:13: error: '__type_pack_element' index is out of range
  237 |     { using type = __type_pack_element<_Np, _Types...>; };
      |             ^~~~
a.cc: In function 'bool tupleSort1(std::tuple<int, int, int>&, std::tuple<int, int, int>&)':
a.cc:17:46: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                        ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:17:46: note: use '-fdiagnostics-all-candidates' to display considered candidates
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                        ~~~~~~^~~
a.cc:17:58: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                                    ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:17:58: note: use '-fdiagnostics-all-candidates' to display considered candidates
   17 |     if (get<2>(a) == get<2>(b)) return get<3>(a) < get<3>(b);
      |                                                    ~~~~~~^~~
a.cc: In function 'bool tupleSort2(std::tuple<int, int, int>&, std::tuple<int, int, int>&)':
a.cc:23:15: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   23 |     if (get<3>(a) == get<3>(b)) return get<2>(a) < get<2>(b);
      |         ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:23:15: note: use '-fdiagnostics-all-candidates' to display considered candidates
   23 |     if (get<3>(a) == get<3>(b)) return get<2>(a) < get<2>(b);
      |         ~~~~~~^~~
a.cc:23:28: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   23 |     if (get<3>(a) == get<3>(b)) return get<2>(a) < get<2>(b);
      |                      ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:23:28: note: use '-fdiagnostics-all-candidates' to display considered candidates
   23 |     if (get<3>(a) == get<3>(b)) return get<2>(a) < get<2>(b);
      |                      ~~~~~~^~~
a.cc:24:18: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   24 |     return get<3>(a) < get<3>(b);
      |            ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:24:18: note: use '-fdiagnostics-all-candidates' to display considered candidates
   24 |     return get<3>(a) < get<3>(b);
      |            ~~~~~~^~~
a.cc:24:30: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 3; _Elements = {int, int, int}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   24 |     return get<3>(a) < get<3>(b);
      |                        ~~~~~~^~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:24:30: note: use '-fdiagnostics-all-candidates' to display considered candidates
   24 |     return get<3>(a) < get<3>(b);
      |                        ~~~~~~^~~