Educational Codeforces Round 88 (Rated for Div. 2) B. New Theatre Square(贪心)
题目链接:https://codeforces.com/contest/1359/problem/B
题意
有一块 $n \times m$ 的地板和两种瓷砖:
- $1 \times 1$,每块花费为 $x$
- $1 \times 2$,每块花费为 $y$
地板为 '.' 表示未铺瓷砖,瓷砖不可旋转, 问铺满瓷砖的最小花费。
题解
因为 $1 \times 2$ 的瓷砖不能旋转,所以每次逐行考虑即可,注意 $y$ 取 $min(2x, y)$ 。
代码
#include <bits/stdc++.h>
using namespace std; void solve() {
int n, m, x, y; cin >> n >> m >> x >> y;
y = min(2 * x, y);
int ans = 0;
for (int i = 0; i < n; i++) {
string s; cin >> s;
for (int j = 0; j < m; j++) {
if (s[j] == '.') {
if (j + 1 < m and s[j + 1] == '.')
ans += y, ++j;
else
ans += x;
}
}
}
cout << ans << "\n";
} int main() {
int t; cin >> t;
while (t--) solve();
}
Educational Codeforces Round 88 (Rated for Div. 2) B. New Theatre Square(贪心)的更多相关文章
- Educational Codeforces Round 88 (Rated for Div. 2) D. Yet Another Yet Another Task(枚举/最大连续子序列)
题目链接:https://codeforces.com/contest/1359/problem/D 题意 有一个大小为 $n$ 的数组,可以选取一段连续区间去掉其中的最大值求和,问求和的最大值为多少 ...
- Educational Codeforces Round 88 (Rated for Div. 2) A. Berland Poker(数学)
题目链接:https://codeforces.com/contest/1359/problem/A 题意 $n$ 张牌可以刚好被平分给 $k$ 个人,其中有 $m$ 张 joker,当一个人手中的 ...
- Educational Codeforces Round 88 (Rated for Div. 2) E. Modular Stability(数论)
题目链接:https://codeforces.com/contest/1359/problem/E 题意 有一大小为 $k$ 的数组,每个元素的值在 $[1,n]$ 间,若元素间两两不等,问有多少数 ...
- Educational Codeforces Round 88 (Rated for Div. 2) C. Mixing Water(数学/二分)
题目链接:https://codeforces.com/contest/1359/problem/C 题意 热水温度为 $h$,冷水温度为 $c\ (c < h)$,依次轮流取等杯的热冷水,问二 ...
- Educational Codeforces Round 88 (Rated for Div. 2) E、Modular Stability 逆元+思维
题目链接:E.Modular Stability 题意: 给你一个n数,一个k,在1,2,3...n里挑选k个数,使得对于任意非负整数x,对于这k个数的任何排列顺序,然后用x对这个排列一次取模,如果最 ...
- Educational Codeforces Round 88 (Rated for Div. 2) D、Yet Another Yet Another Task
题意: 给你一个含n个数a1,a2...an的数组,你要找到一个区间[l,r],使得al+a(l+1)+...+a(r-1)+ar减去max(al,a(l+1),...,a(r-1),ar)的值尽可能 ...
- Educational Codeforces Round 88 (Rated for Div. 2) B、New Theatre Square C、Mixing Water
题目链接:B.New Theatre Square 题意: 你要把所有"." 都变成"*",你可以有两个选择,第一种就是一次铺一个方块(1*1),第二种就是同一 ...
- Educational Codeforces Round 89 (Rated for Div. 2) C. Palindromic Paths(贪心)
题目链接:https://codeforces.com/contest/1366/problem/C 题意 有一个 $n \times m$ 的 $01$迷宫,要使从 $(1,1)$ 到 $(n,m) ...
- Educational Codeforces Round 97 (Rated for Div. 2) D. Minimal Height Tree (贪心)
题意:有一个从根节点\(BFS\)得来的序列(每次\(bfs\)子节点的时候保证是升序放入队列的),现在让你还原树(没必要和之前相同),问能构造出的最小的树的深度. 题解:不看根节点,我们从第二个位置 ...
随机推荐
- Maven 中 install,package,deploy命令区别
mvn clean package依次执行了clean.resources.compile.testResources.testCompile.test.jar(打包)等7个命令. mvn clean ...
- java8 stream api流式编程
java8自带常用的函数式接口 Predicate boolean test(T t) 传入一个参数返回boolean值 Consumer void accept(T t) 传入一个参数,无返回值 F ...
- Oracle获取session的IP方法
方法1 创建触发器: create orreplace trigger login_on alfterlogon on database begin dbms_application_info ...
- 【Oracle】删除(释放)数据文件/表空间流程
oracle删除(释放)数据文件/表空间流程 生产环境:数据库里空间不足,niptest 表空间251G,只使用了17G 再alter database datafile '...../niptest ...
- 【Linux】CentOS7中修改中文字符集
CentOS 7中字符集查看的方式是 locale -a 或者locale 如果想显示中文的话,应该修改为 LANG="zh_CN.UTF-8" 在命令行界面临时修改字符集的话 ...
- 【葵花宝典】All-in-One模式安装KubeSphere
1.准备 Linux 机器 2.google api受限下载 KubeKey export KKZONE=cn curl -sfL https://get-kk.kubesphere.io | VER ...
- DB2版本升级(V9.7升级到V11.1)
1.V11.1版本升级路线 DB2 11.1 可以将现有的 Db2 V9.7.Db2 V10.1 或 Db2 V10.5 实例和数据库直接升级到 Db2 V11.1.如果 Db2 服务器正在 Db2 ...
- 30分钟带你理解 Raft 算法
为什么需要 Raft? Raft 是什么? Raft 的目标 前置条件:复制状态机 Raft 基础 Leader 选举(选举安全特性) 日志复制(Leader只附加.日志匹配) 安全 学习资料 使用 ...
- 無法直接連接互聯網,需要使用代理時(Scrapy)
在windows系統中,如果無法直接連接互聯網,需要使用代理時該怎麽做呢? 1. 在powershell中設置proxy 背景:使用公司電腦,無法直接訪問互聯網,想要訪問互聯網就得使用代理,但是在控制 ...
- OpenStack使用OVN
1. Controller节点 1.1 安装 OVS和OVN 安装 Python3.7: yum -y groupinstall "Development tools" yum - ...