Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
namespace Fast_Read {
	inline void read(int &res) {
		res = 0;int tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
	inline void read(long long &res) {
		res = 0;long long tmp = 1;
		char ch = getchar();
		while (ch < '0' || ch > '9') {if (ch == '-')tmp = -1;ch = getchar();}
		while (ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();
		res *= tmp;
	}
}
using namespace Fast_Read;
const int maxn = 1e5+10;
long long f[maxn],cost[maxn],val[maxn];
int H,n;
int main() {
	read(H);read(n);
	memset(f,0x7f,sizeof(f));
	for (register int i = 1;i <= n;++i)read(cost[i]),read(val[i]);
	f[0] = 0;
	for (register int i = 1;i <= n;++i) {
		int tmp = 2e9+7;
		for (register int j = cost[i];j <= H;++j)
			f[j] = min(f[j],f[j-cost[i]]+val[i]),tmp = min(tmp,f[j]);
		for (register int j = 1;j <= cost[i];++j)
			f[j] = min(f[j],tmp);
	}
	cout<<f[H]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |         for (register int i = 1;i <= n;++i)read(cost[i]),read(val[i]);
      |                           ^
a.cc:30:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |         for (register int i = 1;i <= n;++i) {
      |                           ^
a.cc:32:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |                 for (register int j = cost[i];j <= H;++j)
      |                                   ^
a.cc:33:71: error: no matching function for call to 'min(int&, long long int&)'
   33 |                         f[j] = min(f[j],f[j-cost[i]]+val[i]),tmp = min(tmp,f[j]);
      |                                                                    ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:33:71: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |                         f[j] = min(f[j],f[j-cost[i]]+val[i]),tmp = min(tmp,f[j]);
      |                                                                    ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:34:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |                 for (register int j = 1;j <= cost[i];++j)
      |                                   ^
a.cc:35:35: error: no matching function for call to 'min(long long int&, int&)'
   35 |                         f[j] = min(f[j],tmp);
      |                                ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:35:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   35 |                         f[j] = min(f[j],tmp);
      |                                ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided