「NOIP模拟」小奇挖矿2【动态规划】

注意一下小凯的疑惑的结论即可:

#include 
#include 
#include 
#include 
#include 
#define ll long long
#define rep(i,x,y) for(ll i=(x);i<=(y);i++)
#define repd(i,x,y) for(ll i=(x);i>=(y);i--)
using namespace std;

const ll N=1e5+5;
ll n,m,f[N],mx[N];
ll check[28]={0,1,2,3,0,5,6,0,0,9,10,0,0,13,0,0,0,17,0};
struct node{
	ll a,b;
}c[N];

inline ll read() {
	ll x=0;char ch=getchar();bool f=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return f?-x:x;
}

bool cmp(node p,node q) {
	return p.b=18) {
				f[i]=max(f[i],mx[j]);break;
			}
			
			if(check[c[i].b-c[j].b]) continue;
			
			f[i]=max(f[i],f[j]);
		}
		
		f[i]+=c[i].a;mx[i]=max(mx[i-1],f[i]);
	}
	
	printf("%lld",mx[n]);
	
	return 0;
}

你可能感兴趣的:(NOIP及模拟,动态规划与递推)