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的更多相关文章
随机推荐
- 那些年不错的Android开源项目
那些年不错的Android开源项目 转载自 eoe 那些年不错的Android开源项目-个性化控件篇 第一部分 个性化控件(View) 主要介绍那些不错个性化的View,包括ListView.Acti ...
- loj 1021(状压dp+记忆化搜索)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25887 题目大意:给定的一个某进制下的排列,问它的全排列有多少个能 ...
- SQL经典短小代码收集
--SQL Server:Select TOP N * From TABLE Order By NewID() --开头到N条记录Select Top N * From 表--N到M条记录(要有主索引 ...
- MySQL安装问题:Unable to update security settings解决方案
主要问题还是之前装过,卸载的时候卸载不干净导致的. 如下: 安装到最后出现: Unable to update security settings. Access denied for user 'r ...
- 【BZOJ】1821: [JSOI2010]Group 部落划分 Group(最小生成树+贪心)
http://www.lydsy.com:808/JudgeOnline/problem.php?id=1821 这题裸题. 本题要求最短距离最长,很明显,我们排序. 这里存在贪心,即我们把边权最小的 ...
- shell中(),[]和[[]]的区别
1. 首先,尽管很相似,但是从概念上讲,二者是不同层次的东西."[[",是关键字,许多shell(如ash bsh)并不支持这种方式.ksh, bash(据说从2.02起引入对[[ ...
- 【C语言】04-函数
一.函数的分类 前面已经说过,C语言中的函数就是面向对象中的"方法",C语言的函数可以大概分为3类: 1.主函数,也就是main函数.每个程序中只能有一个.也必须有一个主函数.无论 ...
- [HihoCoder] Highway 高速公路问题
Description In the city, there is a one-way straight highway starts from the northern end, traverses ...
- cvReleaseImage 释放内存出错
cvReleaseImage是OpenCV中C语言库中的释放图片内存的函数,比如我们加载或者克隆了一幅图片,当不需要这幅图片了时,我们为了避免内存泄露,需要释放这些空间,可以参见我之前的博客OpenC ...
- 诅咒JavaScript之----ArcGIS JavaScript 点聚合 ClusterLayer
对一个之前一直做winForm的 菜鸟来说,突然接触这么神奇的语言,基本上每天都会诅咒一下这门神奇的语言. 最近做了一个小网站,底图用的是天地图的服务,用ArcGIS JavaScript提供的一些G ...