ACM: 动态规划题 poj 3211 背包变…
来源:互联网 发布:win7如何安装linux系统 编辑:程序博客网 时间:2024/06/06 23:03
Description
Dearboy was so busy recently that now he has piles of clothes towash. Luckily, he has a beautiful and hard-working girlfriend tohelp him. The clothes are in varieties of colors but each piece ofthem can be seen as of only one color. In order to prevent theclothes from getting dyed in mixed colors, Dearboy and hisgirlfriend have to finish washing all clothes of one color beforegoing on to those of another color.
From experience Dearboy knows how long each piece of clothestakes one person to wash. Each piece will be washed by eitherDearboy or his girlfriend but not both of them. The couple can washtwo pieces simultaneously. What is the shortest possible time theyneed to finish the job?
Input
The input contains several test cases. Each test case beginswith a line of two positive integers M and N(M < 10, N < 100),which are the numbers of colors and of clothes. The next linecontains M strings which are not longer than 10 charactersand do not contain spaces, which the names of the colors. Thenfollow N lines describing the clothes. Each of these linescontains the time to wash some piece of the clothes (less than1,000) and its color. Two zeroes follow the last test case.
Output
For each test case output on a separate line the time the coupleneeds for washing.
Sample Input
3 4
red blue yellow
2 red
3 blue
4 blue
6 red
0 0
Sample Output
10
题意: 一对情侣洗衣服, 现在有m种颜色的衣服n件, 为了不让混着洗衣服染色了, 所以洗完
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 1005
#define MAXSIZE 105
int n, m;
char str[MAXSIZE][12];
int num[MAXSIZE], sum[MAXSIZE], cost[MAX][MAXSIZE];
int dp[MAX*MAXSIZE];
inline int max(int a, int b)
{
}
inline int find(char *ch)
{
}
int DP(int index, int v)
{
}
int main()
{
//
}
- ACM: 动态规划题 poj 3211 背包变…
- ACM: 动态规划题 poj 3093 0-1背包
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 背包问题 动态规划题 toj 133…
- ACM: 0-1背包变形 动态规划题 toj …
- ACM: 简单动态规划题 poj 2955
- ACM: 动态规划题 poj 2241
- ACM: 动态规划题 poj 1054
- ACM: 动态规划题 poj 2948
- ACM: 动态规划题 poj 1925
- ACM: 动态规划题 poj 3034
- ACM: 动态规划题 poj 2411
- ACM: 动态规划题 poj 1947
- ACM: 动态规划题 poj 2486
- ACM: 动态规划题 poj 3140
- ACM: 动态规划题 poj 3659
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 1192 树形DP
- ACM: 动态规划题 poj 3659
- 动态规划: 经典0-1背包问题 (转)
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3211 背包变…
- (OK)(OK) Fedora23——NS3(MANETs)——Docker(busybox)——genymotion(android)——All is OK
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 3093 0-1背包
- ACM: 动态规划题 poj&nb…
- ACM: 动态规划题 poj 2923
- 兴趣学习: opencv -- 视频读写, 鼠…
- 兴趣学习: opencv 实现画图程序
- ACM: 图论题 poj 3…