LightOJ 1017 - Brush (III)(dp)
来源:互联网 发布:电子仿真软件列表 编辑:程序博客网 时间:2024/05/22 01:37
题目链接:LightOJ 1017 - Brush (III)
代码
#include <cstdio>#include <cstring>#include <vector>#include <algorithm>using namespace std;const int maxn = 105;int N, W, M, G[maxn], Y[maxn];void init () { scanf("%d%d%d", &N, &W, &M); int x; for (int i = 0; i < N; i++) scanf("%d%d", &x, &Y[i]); sort(Y, Y + N); x = 0; for (int i = 0; i < N; i++) { while (x < N && Y[x] <= Y[i] + W) x++; G[i] = x; }}int dp[maxn][maxn];int solve () { memset(dp, 0, sizeof(dp)); for (int i = 1; i <= M; i++) { for (int j = 0; j < N; j++) { dp[i][G[j]] = max(dp[i][G[j]], dp[i-1][j] + G[j] - j); dp[i][j+1] = max(dp[i][j+1], dp[i][j]); } } return dp[M][N];}int main () { int cas; scanf("%d", &cas); for (int kcas = 1; kcas <= cas; kcas++) { init(); printf("Case %d: %d\n", kcas, solve()); } return 0;}
0 0
- LightOJ 1017 - Brush (III) (dp)
- LightOJ 1017 - Brush (III)(dp)
- lightoj 1017 - Brush (III)(dp)
- LightOJ - 1017 Brush (III) (DP)
- LightOJ 1017 Brush (III) (DP)
- lightoj 1017 - Brush (III) (DP)
- LightOJ 1017 Brush (III) 【DP】
- LightOJ 1017 Brush (III) (DP)
- Lightoj - 1017 - Brush (III) 详解(经典线性DP)
- LightOJ 1017 - Brush (III)【一般DP】
- lightoj 1017 Brush (III) 基础DP
- lightoj 1017 - Brush (III) 【离散化 + dp】
- lightoj 1017 - Brush (III)
- LightOJ - 1017 Brush (III)
- LightOJ 1017 - Brush (III)
- LightOJ 1017 - Brush (III)
- LightOJ 1017 Brush (III)
- lightoj 1017 - Brush (III)
- 用贪心算法解决背包问题
- 欢迎使用CSDN-markdown编辑器
- memmem()和strstr()函数
- lightoj 1297 Largest Box
- 华为OJ题目(三):字符统计
- LightOJ 1017 - Brush (III)(dp)
- Jump Game (Medium)
- QT+openGL
- C# LINQ to SQL快速上手
- Spring的事务管理对何种异常进行回滚
- http://blog.csdn.net/jadyer/article/details/6013743
- 顺序队列的算法操作
- iOS多线程 GCD NSoperation NSThread
- 编程之美-最短摘要的生成方法整理