Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
ll dp[30000][30000];
ll a[1100],b[1100];
ll h,n;
void solve(){
    for (ll i=0;i<n;i++){
        for (ll j=0;j<30000;j++){
            if (j<b[i]){
                dp[i][j]=dp[i+1][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-b[i]]+a[i]);
            }
        }
    }
}
int main(){
    ll ans=INF;
    cin>> h >> n;
    for (ll i=0;i<n;i++){
        cin>> a[i] >> b[i];
    }
    solve();
    for (ll i=0;i<30000;i++){
        if (dp[n][i]>=h){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}




Compiler output:
/tmp/ccQzyn68.o: in function `solve()':
a.cc:(.text+0x3c2): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x43a): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x475): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x4fe): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQzyn68.o
/tmp/ccQzyn68.o: in function `main':
a.cc:(.text+0x529): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x545): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x56d): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x598): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x5b2): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x5ce): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccQzyn68.o
a.cc:(.text+0x5f6): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status