Educational Codeforces Round 102 Personal Editorial(A~C,max Rating 1500)
1473A. Replacing Elements Rating 800
对数组排序,一旦数组中最大的数即a[n-1]是一个小于或等于d的数,直接输出YES即可,否则运用数组中最小的两个数加和替换最大的数。
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
for (cin >> _; _--;) {
int n, d;
cin >> n >> d;
vector<int> a(n);
for (auto &i : a) cin >> i;
sort(a.begin(), a.end());
cout << (a[n - 1] <= d || a[0] + a[1] <= d ? "YES\n" : "NO\n");
}
return 0;
}
1473B. String LCM Rating 1000
给两个只由a和b组成的字符串,让你求出即符合a的变化规律又符合b的变化规律的,长度即能被a的长度整除也能被b的长度整除的最短字符串。
那么模拟一下过程即可
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
for (cin >> _; _--;) {
string a, b;
cin >> a >> b;
string p = a, q = b;
while (true) {
if (p.length() == q.length()) {
if (p == q)
cout << p << endl;
else
cout << -1 << endl;
break;
}
if (p.length() < q.length())
p += a;
else
q += b;
}
}
return 0;
}
1473C. No More Inversions Rating 1500
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
for (cin >> _; _--;) {
int n, k;
cin >> n >> k;
for (int i = 1; i < 2 * k - n; i++) cout << i << ' ';
// 2 * k - n即 k - (n - k)的变形
for (int i = k; i >= 2 * k - n; i--) cout << i << ' ';
cout << endl;
}
return 0;
}
Educational Codeforces Round 102 Personal Editorial(A~C,max Rating 1500)的更多相关文章
- Educational Codeforces Round 51 D. Bicolorings(dp)
https://codeforces.com/contest/1051/problem/D 题意 一个2*n的矩阵,你可以用黑白格子去填充他,求联通块数目等于k的方案数,答案%998244353. 思 ...
- Educational Codeforces Round 102 (Rated for Div. 2)
比赛地址 A(水题) 题目链接 题目: 给出一个数组\(a\)并能进行一个操作使得数组元素更改为数组任意其他两元素之和,问是否可以让数组元素全部小于等于\(d\) 解析: 排序后判断最大值是否小于等于 ...
- Educational Codeforces Round 42D. Merge Equals(STL)
D. Merge Equals time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 102 (Rated for Div. 2) D. Program (思维,前缀和)
题意:给你一个只含\(+\)和\(-\)的字符串,给你一个数\(x\),\(x\)初始为\(0\),随着字符串的遍历会加一减一,现在有\(m\)个询问,每个询问给出一个区间\([l,r]\)表示将这个 ...
- Educational Codeforces Round 102 (Rated for Div. 2) B. String LCM (构造,思维)
题意:给你两个字符串\(a\)和\(b\),找出它们的\(lcm\),即构造一个新的字符串\(c\),使得\(c\)可以由\(x\)个\(a\)得到,并且可以由\(y\)个\(b\)得到,输出\(c\ ...
- Educational Codeforces Round 76 (Rated for Div. 2)E(dp||贪心||题解写法)
题:https://codeforces.com/contest/1257/problem/E 题意:给定3个数组,可行操作:每个数都可以跳到另外俩个数组中去,实行多步操作后使三个数组拼接起来形成升序 ...
- Educational Codeforces Round 64 (Rated for Div. 2) A,B,C,D,E,F
比赛链接: https://codeforces.com/contest/1156 A. Inscribed Figures 题意: 给出$n(2\leq n\leq 100)$个数,只含有1,2,3 ...
- Codeforces Round #370 (Div. 2)(简单逻辑,比较水)
C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- CodeForces - 150C :Smart Cheater (线段树,求最大连续区间)
I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increas ...
- Educational Codeforces Round 26
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...
随机推荐
- 金蝶云星空与泛微OA集成的方案落地与实践
打破信息孤岛,泛微OA集成的方案落地与实践 在现代企业内部,不同类型的业务系统和泛微OA平台层出不穷.企业需要找到一种高效的方法来整合和协同这些多样化的系统,同时将它们与泛微OA平台融合,以实现资源整 ...
- [ABC261E] Many Operations
Problem Statement We have a variable \(X\) and \(N\) kinds of operations that change the value of \( ...
- liunx系统登录有趣界面图案
# vim /etc/motd .::::. .::::::::. ::::::::::: ..:::::::::::' '::::::::::::' .:::::::::: '::::::::::: ...
- HBase的实验原理
功能组件: master Region Region到底被存到哪里去了 HBase的三层结构 三层结构中各个层次的名称和作用
- C++学习笔记四:变量与数据类型(布尔型与字符型)
今天来整理一下布尔型和字符型变量的基本使用方法1)布尔型变量1. 声明和初始化一个布尔类型的变量占据1 Byte空间,数值0代表false,其他非0数值代表true bool red_light {f ...
- .NET周刊【12月第1期 2023-12-06】
国内文章 .NET 与 OpenEuler 共展翅,昇腾九万里 https://www.cnblogs.com/shanyou/p/17858385.html 本文介绍了openEuler操作系统,它 ...
- Android对接微信登录记录
Android对接微信登录记录 - Stars-One的杂货小窝 Android项目要对接下微信登录,稍微记录下踩坑点 代码 1.添加依赖 implementation 'com.tencent.mm ...
- SpringCloud OpenFeign的使用
SpringCloud OpenFeign的使用 是什么: 声明式http客户端. 目的: 使远程调用更简单 作用: 提供了http请求模板,仅需编写简单接口和插入注解,就可以定义好原始http请求的 ...
- 复现YOLO5所遇到的问题
一. 解决方案: 由于没有影响模型继续运行,理解为简单的warning.根据查询问题,推断是由于 pytorch和torchvision的版本原因导致的. 二. 解决方案: 由于没有影响模型继续运行, ...
- Linux-LVM 磁盘扩容
LVM技术详解:视频1.视频2.视频3 安装lvm2后才支持如下命令 yum install -y lvm2 序号 功能 PV物理卷命令 VG卷组命令 LV逻辑卷命令 01 扫描功能 pvscan v ...