本文共 531 字,大约阅读时间需要 1 分钟。
突破口:只要发现DP对象是间歇M,便可发现本质是最大递增子序列。
代码如下:
#include#include #include #include using namespace std;long long dp[1005];struct mt{ int s,t,e;}m[1005];bool cmp(mt x,mt y){ if(x.t!=y.t) return x.t >N>>M>>R; for(i=0;i<=M-1;i++) cin>>m[i].s>>m[i].t>>m[i].e; sort(m,m+M,cmp); // for(i=0;i<=M-1;i++) // cout< <<' '< <<' '< < N) break; if(i==0) ans=dp[i]=m[i].e; else { temp=0; for(j=i-1;j>=0;j--) { if(m[i].s-m[j].t>=R) { if(temp
Tips:DP需确定准对象。
转载地址:http://abdci.baihongyu.com/