#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <cmath>
#include <map>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 1000005;
const int INF = 0x3f3f3f3f;
#define IOS ios::sync_with_stdio(false);
int T, M;
int t[10005];
int v[10005];
ll dp[10000010];
void solve() {
for (int i = 1; i <= M; i++) {
for (int j = t[i]; j <= T; j++) {
dp[j] = max(dp[j], dp[j - t[i]] + v[i]);
}
}
printf("%lld\n", dp[T]);
}
int main() {
scanf("%d %d", &T, &M);
for (int i = 1; i <= M; i++) {
scanf("%d %d", t + i, v + i);
}
solve();
return 0;
}
P1616 疯狂的采药(完全背包)
最新推荐文章于 2024-08-14 11:57:07 发布