Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
LIS简单变式#include<cstdio> #include<algorithm> using namespace std; struct node{ int s,e,c; }a[1005]; bool cmp(node x,node y){ return x.s<y.s; } int n,m,r,res,dp[1005]; int main(){ scanf("%d%d%d",&n,&m,&r); for(int i=1;i<=m;++i) scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].c); sort(a+1,a+m+1,cmp); for(int i=1;i<=m;++i) dp[i]=a[i].c; for(int i=2;i<=m;++i){ for(int j=i-1;j>=1;--j) if(a[j].e+r<=a[i].s) dp[i]=max(dp[i],dp[j]+a[i].c); if(dp[i]>res) res=dp[i]; } printf("%d\n",res); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator