题目链接:uva 1366 - Martian Mining
题目大意:给出n和m,然后给出两种矿的分布,a种只能向上运输,b中只能向下运输,问说最多可以得到多少。
解题思路:dp[i][j]表示矩阵i,j的最大值,dp[i][j]= max(dp[i-1][j]+suma[i][j], dp[i][j-1] + sumb[i][j]).\
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 505;
int n, m, a[N][N], b[N][N], dp[N][N];
void init () {
int k;
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d", &a[i][j]);
a[i][j] += a[i][j-1];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%d", &b[i][j]);
b[i][j] += b[i-1][j];
}
}
}
int solve () {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
dp[i][j] = max(dp[i-1][j] + a[i][j], dp[i][j-1] + b[i][j]);
}
}
return dp[n][m];
}
int main () {
while (scanf("%d%d", &n, &m) == 2 && n + m) {
init();
printf("%d\n", solve());
}
return 0;
}
分享到:
相关推荐
开源项目-google-martian.zip,Martian - HTTP proxy designed for E2E testing
Martian-Harmony-2.0 这个想法是建立一个可以像人类一样演奏乐器的机器人。 它由各种乐器组成,如长笛、键盘、吉他等。所有这些乐器都使用不同的机制演奏。 团队成员 希瓦姆·马卢 什哈尔·巴尔加瓦 乌梅什·...
Martian-Harmony-3.0 印度第一个机器人乐队 抽象的 这个项目的想法是制作印度第一个机器人乐队。该团队在过去三年中一直致力于这个项目,并且每年团队都试图构建能够演奏特定乐器的机器人。在过去两年中,三个乐器...
远藤火星人 一个在“火星人通知者”手表上提供Endomondo通知的应用程序。 它捕获发送到Pebble的广播并创建通知。
➜ ~/www/save-martian $ publoy >>> Publoying... >>> Syncing to Dropbox... >>> done. > Share link: (Syncing...) https://dl.dropboxusercontent.com/u/1218282/publoy/save-martian/index.html 作者 Abhinay ...
或作为插件构建go build -buildmode=plugin -o krakend-martian_header-ro.so ./header/rollover ./krakend run -c krakend.json 笔记 网站开发作为系统管理员 如何使用Golang插件和KrakenD
基于AIO的网络编程包项目简介Martian-Server 是一个基于AIO的网络编程包,支持http,websocket等协议【暂时只支持http】安装步骤一、导入依赖<dependency> <groupId>...!-- 这个是日志包,支持任意可以跟slf4j桥接的包 ...
1我们按照“ martian source”在Linux内核当中进行检索,发现该日志错误是在ip_handle_martian_source()这个函数中打印的 /* https://github.com/torvalds/linux/blob/master/net/ipv4/route.c */ static void ip_...
这就像一个浮动的轴承球,但它是立方的--martian17 就个人而言,无限摩擦是最令人满意的
( let [m ( martian-http/bootstrap-openapi " https://pedestal-api.herokuapp.com/swagger.json " )] ( martian/response-for m :create-pet { :name " Doggy McDogFace " :type " Dog " :age 3 }) ; ; => {:...
火星框架父 超级POM 阿帕奇Maven <groupId>io.github.marsianer <artifactId>martian-framework-parent <version>21.04.00.00 执照 根据Apache License 2.0分发。 有关更多信息,请参见。
基于AIO的网络编程包 ... <artifactId>Martian-server 最新版 <!-- 这个是日志包,支持任意可以跟slf4j桥接的包 --> <groupId>org.slf4j <artifactId>slf4j-jdk14 <version>1.7.12 二
寻找Martian Night 。 单击安装进行安装。 代码>首选项>颜色主题>火星之夜 贡献 克隆此仓库并在VS Code中打开 打开运行View → Run 单击Launch Extension 。 这将打开另一个VS代码编辑器 对Martian Night-color-...
火星机器人追踪器 追踪火星上的所有机器人! 作为的第一关,我使用了在您的终端中运行的基于 javascript 的测试驱动解决方案。 安装 npm install 跑步 jasmine-node spec/ --verbose
火星框架jaxb 该软件包提供了有用的辅助类,这些辅助类简化了的使用。... <artifactId>martian-framework-jaxb <version>21.04.00.00 执照 根据Apache License 2.0分发。 有关更多信息,请参见。
Martian Aptos Wallet_v0.2.2.crx
cd martian-robots npm install 在命令行上: node cli.js -i example/input.txt 在浏览器中: [removed][removed] [removed] var Controller = require('./lib/controller.js').Controller; ... [removed] ...
git clone https://github.com/HurricaneJames/martian-robots.git npm install # if you want to see tests npm test # launch the runner npm run start # load browser at http://localhost:8090 使用 输入文本...
Structural response of an inflatable module for a lunar&Martian base