Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C)
1499A. Domino on Windowsill
题意:给定一个 \(2 \times n\) 的空间,\(k1、k2 行要设置为白色(2 \times 1)\) 然后其他的设置为黑色
思路:为了满足条件需要判断一下白色和黑色的方块是否足够。
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _ = 1;
for (cin >> _; _--;) {
int n, k1, k2, w, b;
cin >> n >> k1 >> k2 >> w >> b;
if (2 * w <= k1 + k2 and 2 * b <= 2 * n - k1 - k2) cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
1499B. Binary Removals
找下前缀的 0和后缀的 1的个数进行比较
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _ = 1;
for (cin >> _; _--;) {
string s;
cin >> s;
int L = 0, R = s.size() - 1;
while (L < s.size() and (s[L] == '0' or (L == 0 or s[L - 1] == '0')))
L++;
while (R >= 0 and
(s[R] == '1' or (R == (int)s.size() - 1 or s[R + 1] == '1')))
R--;
if (L >= R) cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
学习高 Rank 的大佬写法
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _ = 1;
for (cin >> _; _--;) {
string s;
cin >> s;
int i = s.find("11");
int j = s.rfind("00");
cout << (i != -1 && j != -1 && i < j ? "NO" : "YES") << endl;
}
return 0;
}
1499C. Minimum Grid Path
using ll = long long;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int _ = 1;
for (cin >> _; _--;) {
int n;
cin >> n;
vector<int> c(n);
ll ans = LLONG_MAX;
ll mi[2] = {(ll)1E13, (ll)1E13}, sm[2] = {0, 0}, cnt[2] = {0, 0};
for (int i = 0; i < n; ++i) {
ll c;
cin >> c;
mi[i & 1] = min(mi[i & 1], c);
cnt[i & 1] += 1;
sm[i & 1] += c;
ans = min(ans, mi[0] * (n - cnt[0]) + sm[0] + mi[1] * (n - cnt[1]) +
sm[1]);
}
cout << ans << "\n";
}
return 0;
}
Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C)的更多相关文章
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
- Educational Codeforces Round 59 (Rated for Div. 2) DE题解
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...
- Educational Codeforces Round 106 (Rated for Div. 2)
就ac了2题... A题一开始题意模模糊糊的似懂非懂,然后自己按样例推出了题意,简单题很容易ac了.还是自己的英语水平太菜了.... B题根据0和1的位置关系能看出来,因为0不能在1后面, 所以有00 ...
- Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解
题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...
- Educational Codeforces Round 80 (Rated for Div. 2)部分题解
A. Deadline 题目链接 题目大意 给你\(n,d\)两个数,问是否存在\(x\)使得\(x+\frac{d}{x+1}\leq n\),其中\(\frac{d}{x+1}\)向上取整. 解题 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
随机推荐
- MySQL-char与 varchar 的区别?
版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin 1.共同点: 都是字符串类型 2.不同点: ①.char类型是定长数据类型.,对于数据插入的速度比较块,在有大量插入需 ...
- StackGres 数据库平台工程,使用 Citus + Patroni 创建生产级高可用分布式 PostgreSQL 分片集群
系列 StackGres, 可私有部署的云原生数据库平台工程 StackGres 数据库平台工程功能介绍与快速上手 StackGres 1.6 数据库平台工程集群配置管理(K8S Pods/Postg ...
- [THUPC 2023 初赛] 背包
题目描述 本题中,你需要解决完全背包问题. 有 \(n\) 种物品,第 \(i\) 种物品单个体积为 \(v_i\).价值为 \(c_i\). \(q\) 次询问,每次给出背包的容积 \(V\),你需 ...
- 什么是革命性技术eBPF?为什么可观测性领域都得用它
公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享. 如果有一种技术可以监控和采集任何应用信息,支持任何语言,并且应用完全无感知,零侵入,想想是不是很激动,那么这个技术是什么呢 ...
- ElasticSearch之健康状态
参考Cluster health API. 命令样例,如下: curl -X GET "https://localhost:9200/_cluster/health?wait_for_sta ...
- 支付宝沙箱支付-zfbsxzf
title: 支付宝沙箱支付 date: 2022-03-03 13:55:15.281 updated: 2022-03-10 16:00:42.331 url: https://www.yby6. ...
- 2023河南省第五届“金盾信安杯”CRYPTO MISC 复现
MISC 来都来了 题目 我的解答: 给了一个加密压缩包,010查看发现是伪加密,修改如下两部分: 头部和尾部的09分别改为00 然后解压得到: 尝试base64解码得到很零散的结果..大眼一看不知道 ...
- 你真的会用 npx 吗❓❓❓
Hello,大家好! 日常开发中大家应该经常使用 npm install xxx 来安装包依赖,那是否注意到npm升级到 npm@5.2.0 之后,在 npm 二进制命令旁边安装了一个 npx 二进制 ...
- 文心一言 VS 讯飞星火 VS chatgpt (35)-- 算法导论5.3 5题
五.证明:在过程 PERMUTE-BY-SORTING的数组 P中,所有元素都唯一的概率至少是1-1/n. 文心一言: 证明: 在过程PERMUTE-BY-SORTING中,对于输入数组P中的每个元素 ...
- Llama2-Chinese项目:8-TRL资料整理
TRL(Transformer Reinforcement Learning)是一个使用强化学习来训练Transformer语言模型和Stable Diffusion模型的Python类库工具集, ...