标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 3665 Accepted Submission(s): 1452
#include<stdio.h> #include<queue> #include<iostream> #include <string.h> #include <algorithm> #include <map> using namespace std; typedef long long LL; int n,m; int dp[105]; ///dp[i] 代表前 i 天能够获得最多的收益 int val[105][105]; ///val[i][j] 代表从第 i 天到第 j 天能够获得的收益 int main() { int tcase; scanf("%d",&tcase); while(tcase--){ memset(val,0,sizeof(val)); scanf("%d%d",&m,&n); int id = 0; for(int i=0;i<n;i++){ int s,e,c; scanf("%d%d%d",&s,&e,&c); val[s][e] = max(val[s][e],c); } memset(dp,0,sizeof(dp)); for(int i=1;i<=m;i++){ for(int j=0;j<i;j++){ dp[i] = max(dp[i],dp[j]+val[j+1][i]); } } printf("%d\n",dp[m]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5595024.html