Educational Codeforces Round 106 (Rated for Div. 2) 简单题解(A~C)
1499A. Domino on Windowsill
题意:给定一个
思路:为了满足条件需要判断一下白色和黑色的方块是否足够。
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;
}
分类:
刷题笔记: CF
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· 分享4款.NET开源、免费、实用的商城系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 全程不用写代码,我用AI程序员写了一个飞机大战
2020-03-20 LeetCode | 160. 相交链表
2020-03-20 LeetCode | 287. 寻找重复数
2020-03-20 LeetCode | 142. 环形链表 II
2020-03-20 LeetCode | 141. 环形链表