Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const ll inf = (ll)1e16;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
ll dp[3][40],n,t,ans;
bool compare(pii a, pii b)
{
	return a.fi*(b.se+1) > b.fi*(a.se+1);
}
int main()	
{
	//freopen(file".inp","r",stdin);
	//freopen(file".out","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>t;
	vector<pii> arr;
	vector<ll> zero;
	for(int i=0;i<n;i++)
	{
		pii temp;
		cin>>temp.fi>>temp.se;
		if(temp.fi == 0)
			zero.eb(temp.se);
		else
			arr.eb(temp);
	}
	sort(arr.begin(),arr.end(),compare);
	for(int i=0;i<2;i++)
		for(int j=0;j<33;j++)
			dp[i][j] = inf;
	dp[0][0] = 0;
	for(int i=0;i<arr.size();i++)
	{
		for(int j=0;j<33;j++)
			dp[(i+1)&1][j] = inf;
		auto s = arr[i];
		for(int j=0;j<33;j++)
		{
			if(dp[i&1][j]==inf)
				continue;
			dp[(i+1)&1][j] = min(dp[(i+1)&1][j],dp[i&1][j]);
			ll check = (dp[i&1][j]+1)*(s.fi+1)+s.se;
			if(check<=t and j+1<33)
				dp[(i+1)&1][j+1] = min(dp[(i+1)&1][j+1],check);	
		}	
	}
	sort(zero.begin(),zero.end());
	vector<ll> pref(zero.size()+1);
	pref[0] = 0;
	for(int i=0;i<zero.size();i++)
		pref[i+1] = pref[i]+zero[i]+1;
	for(int j=0;j<33;j++)
	{
		ll res = t-dp[arr.size()&1][j];
		if(res<0)
			continue;
		ans = max(ans,upper_bound(pref.begin(),pref.end(),res)-pref.begin()+j-1);
	}
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:26: error: no matching function for call to 'max(long long int&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   71 |                 ans = max(ans,upper_bound(pref.begin(),pref.end(),res)-pref.begin()+j-1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:71:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   71 |                 ans = max(ans,upper_bound(pref.begin(),pref.end(),res)-pref.begin()+j-1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:71:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   71 |                 ans = max(ans,upper_bound(pref.begin(),pref.end(),res)-pref.begin()+j-1);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~