poj 2626 三维dp 0 1 bag
来源:互联网 发布:s7200梯形图编程实例 编辑:程序博客网 时间:2024/06/01 10:04
Chess
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2529 Accepted: 1159
Description
The Association of Chess Monsters (ACM) is planning their annual team match up against the rest of the world. The match will be on 30 boards, with 15 players playing white and 15 players playing black. ACM has many players to choose from, and they try to pick the best team they can. The ability of each player for playing white is measured on a scale from 1 to 100 and the same for playing black. During the match a player can play white or black but not both. The value of a team is the total of players' abilities to play white for players designated to play white and players' abilities to play black for players designated to play black. ACM wants to pick up a team with the highest total value.
Input
Input consists of a sequence of lines giving players' abilities. Each line gives the abilities of a single player by two integer numbers separated by a single space. The first number is the player's ability to play white and the second is the player's ability to play black. There will be no less than 30 and no more than 1000 lines on input.
Output
Output a single line containing an integer number giving the value of the best chess team that ACM can assemble.
Sample Input
87 8466 7886 9493 8772 10078 6360 9177 6477 9187 7369 6280 6881 8374 6386 6853 8059 7368 7057 9493 6274 8070 7288 8575 9971 6677 6481 9274 5771 6382 9776 56
Sample Output
2506
题意:
这里就是说需要找十五个下黑棋,十五个下白棋子的人
题目中每一个人下 黑 白的不同的战斗力,然后求出这个队可以选出的最大的战斗力
三维dp,以dp[i][j][k]表示从前i个人中选j个下黑子k个下白子的最大能力值,以 a[ i ][ 0 ]和 a[ i ][ 1 ]表示第i名选手下黑白子的能力,那么轻易得出递推方程
dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k]+a[ i ][ 0 ],dp[i-1][j][k-1]+a[ i ][ 1 ] )
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[1010][3];int dp[1010][20][20];int main(){ int pos=0; while(~scanf("%d%d",&a[pos][0],&a[pos][1])) pos++; dp[0][1][0]=a[0][0]; dp[0][0][1]=a[0][1]; for(int i=1;i<pos;i++) for(int j=0;j<16;j++) for(int k=0;k<16;k++){ if(j) dp[i][j][k]=max(dp[i][j][k],max(dp[i-1][j][k],dp[i-1][j-1][k]+a[i][0])); if(k) dp[i][j][k]=max(dp[i][j][k],max(dp[i-1][j][k],dp[i-1][j][k-1]+a[i][1])); } printf("%d\n",dp[pos-1][15][15]); return 0;}
0 0
- poj 2626 三维dp 0 1 bag
- POJ 1946(三维DP)
- poj 1695(三维dp)
- POJ 1185 炮兵阵地 三维DP *
- poj 3042 Grazing on the Run(区间DP,三维DP)
- 【状态dp】poj 1185 炮兵阵地(三维dp)
- hdu 5234 Happy birthday【dp】【三维0-1背包】
- POJ 3034 Whac-a-Mole(三维dp+处理小技巧)
- POJ 2152 Check the difficulty of problems(三维dp)
- POJ 3042 Grazing on the Run (三维区间DP)【区间DP模板】
- POJ2626 chess 三维DP
- hdu4826(三维DP)
- NOJ1859 越野赛 三维DP
- hdu 4427 三维dp
- 【DP 三维数组】UVA
- CF148D. Bag of mice(概率DP)
- CF D. Bag of mice(概率dp)
- CF148D--Bag of mice+概率期望dp
- M2_REPO
- Android:Date、String、Long三种日期类型之间的相互转换
- Could not connect to Redis No route to host问题解决
- A2P模式下的e租宝是否值得投资
- Windows10下u盘安装Ubuntu系统经验分享
- poj 2626 三维dp 0 1 bag
- MySQL安装
- 缓冲区溢出攻击
- 能够与服务器连接交互的拥有界面的客户端-------------聊天窗口(实现群聊)
- RoundCornerTextview2
- SQL语句中的查询操作
- Python常用的字符串处理函数
- C++第二次实验
- CF 627A. XOR Equation 位运算