[success]原题: https://www.luogu.org/problem/show?pid=1280[/success]
解法:
本来想到的是排个序然后根据K排序...
然后...
没有想到怎么做...
然后无奈看题解...
发现我想多了【捂脸】
不要想得太复杂!!明明是你弱
代码:
[code lang="cpp"]
#include<cstdio>
#include<cstring>
#include<iostream>
#define INF 0x3f3f3f3f
#define MAXN 10010
using namespace std;
struct task{
int b, l;
}t[MAXN];
int dp[MAXN];
int main(){
int ans = 0;
int n, k;
scanf("%d%d", &n, &k);
for (int i = 0; i < k; i++)
scanf("%d%d", &t[i].b, &t[i].l);
bool fe;
dp[n + 1] = 0;
for (int i = n; i >= 1; i--){
fe = 1;
for (int j = 0; j < k; j++){
if (t[j].b == i){
fe = 0;
dp[i] = max(dp[i], dp[i + t[j].l]);
}
}
if (fe) dp[i] = dp[i + 1] + 1;
}
printf("%d", dp[1]);
}
[/code]
Comments
(Participate in the discussion)
Comments
No comments found.
No comments found.