xinwajueji
#include<stdio.h> int map[10][10]={0}; int step[30]={0}; int max=99999; int ans[99]={0}; int C1; int R1; int M1; int C2; int R2; int M2; int N; int H; int V; int T; void qian() { int i=0; int j=H-1; int a=0; int sum=0; while(i<=j) { if(step[a]==1) { if(a-1>=0&&step[a]==step[a-1]) { sum+=R1; } sum=sum+C1*map[0][i]; if(sum>max) break; i++; a++; } else if(step[a]==0) { if(a-1>=0&&step[a]==step[a-1]) { sum+=R2; } sum=sum+C2*map[0][j]; if(sum>max) break; j--; a++; } } if(max>sum) { max=sum; } } void keneng(int a) { if(a==H) { /*for(int b=0;b<3;b++) { printf("%d",step[b]); }printf("\n");*/ qian(); return; } for(int i=0;i<2;i++) { step[a]=i; keneng(a+1); } } int main() {
freopen("in.txt","r",stdin); scanf("%d",&T); while(T--) { scanf("%d%d%d",&N,&H,&V); for(int i=0;i<V;i++) { for(int j=0;j<H;j++) { scanf("%d",&map[i][j]); } } scanf("%d%d%d",&C1,&R1,&M1); scanf("%d%d%d",&C2,&R2,&M2); keneng(0); printf("%d\n",max); } /*for(int q=0;q<V;q++) {
} for(int i=0;i<N;i++) {
ans[i]=max;*/ return 0; }
xinwajueji的更多相关文章
随机推荐
- hdu 1556 树状数组+点查询
树状数组 N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一 ...
- poj 1236 scc强连通分量
分析部分摘自:http://www.cnblogs.com/kuangbin/archive/2011/08/07/2130277.html 强连通分量缩点求入度为0的个数和出度为0的分量个数 题目大 ...
- Codeforces Round #352 (Div. 2) C. Recycling Bottles 贪心
C. Recycling Bottles It was recycling day in Kekoland. To celebrate it Adil and Bera went to Centr ...
- HDU 4345 Permutation dp
Permutation Problem Description There is an arrangement of N numbers and a permutation relation that ...
- loadrunner关联数组后拼凑字符串
loadrunner拼接关联数组的元素 int arrSize=0; int index=1; int len=0; char arryStartString[1024]=""; ...
- mysql优化连接数防止访问量过高的方法
这篇文章主要介绍了mysql优化连接数防止访问量过高的方法,需要的朋友可以参考下 很多开发人员都会遇见”MySQL: ERROR 1040: Too many connections”的异常情况,造成 ...
- HDU2196 Computer(树形DP)
和LightOJ1257一样,之前我用了树分治写了.其实原来这题是道经典的树形DP,感觉这个DP不简单.. dp[0][u]表示以u为根的子树中的结点与u的最远距离 dp[1][u]表示以u为根的子树 ...
- SPOJ962 Intergalactic Map(最大流)
题目问一张无向图能否从1点走到2点再走到3点,且一个点只走一次. 思维定势思维定势..建图关键在于,源点向2点连边,1点和3点向汇点连边! 另外,题目数据听说有点问题,出现点大于n的数据.. #inc ...
- bzoj1028 [JSOI2007]麻将
1028: [JSOI2007]麻将 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 1337 Solved: 601[Submit][Status][ ...
- POJ 2104 K-th Number(划分树)
题目链接 参考HH大神的模版.对其中一些转移,还没想清楚,大体明白上是怎么回事了,划分树就是类似快排,但有点点区别的.多做几个题,慢慢理解. #include <cstdio> #incl ...