Educational Codeforces Round 148 [Rated for Div. 2]A~C
A
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 60;
char c[N];
void run()
{
scanf("%s", c + 1);
int n = strlen(c + 1);
map<char, int>st;
st[c[1]] ++;
for(int i = 2; i <= n / 2; ++ i)
{
if(st.find(c[i]) == st.end())
{
printf("YES\n");
return;
}
}
printf("NO\n");
}
int main()
{
// freopen("1.in", "r", stdin);
int t;cin >> t;
while(t --) run();
return 0;
}
B
直接枚举即可
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int a[N];
LL s[N];
void run()
{
int n, k;
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
sort(a + 1, a + 1 + n);
for(int i = 1; i <= n; ++ i) s[i] = s[i - 1] + a[i];
LL ans = 0;
for(int i = 0; i <= k; ++ i)
{
int l = 2 * (k - i), r = n - i;
ans = max(ans, s[r] - s[l]);
}
printf("%lld\n", ans);
}
int main()
{
// freopen("1.in", "r", stdin);
int t;cin >> t;
while(t --) run();
return 0;
}
C
C比赛时没出,思路上没什么大问题,就是差一点(bushi,说到底还是自己菜)
我们可以发现这道题只需要找一下有多少个波峰和波谷就可以了,因为波峰波谷一定不能删除
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 3e5 + 10;
void run()
{
int n;
scanf("%d", &n);
vector<int>a(n);
for(int i = 0; i < n; ++ i) scanf("%d", &a[i]);
n = unique(a.begin(), a.end()) - a.begin();
int ans = 0;
for(int i = 0; i < n; ++ i)
{
if(i == 0 || i == n -1 || a[i] > a[i - 1] == a[i] > a[i + 1]) ans ++;
}
printf("%d\n", ans);
}
int main()
{
// freopen("1.in", "r", stdin);
int t;cin >> t;
while(t --) run();
return 0;
}
Educational Codeforces Round 148 [Rated for Div. 2]A~C的更多相关文章
- 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 ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 39 (Rated for Div. 2) G
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...
- 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 60 (Rated for Div. 2) 题解
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...
随机推荐
- 2021-7-11 Vue的自定义指令简单实例
获取焦点简单实例,用Vue.directive(ps:指令)定义,命名不要是关键字,用v-加自定义指令名称调用,而内部用钩子函数inserted来实现 <!DOCTYPE html> &l ...
- BurpSuite设置上游代理访问内网
转载原文 原理知道了后,开始! 拿到B的shell后,添加路由 拿到B的shell后,开启sock4 在D主机上设置好 最后成功抓到包
- VMware中的三种网络模式
1.桥接模式网络 通过桥接模式网络连接,虚拟机中的虚拟网络适配器可连接到主机中的物理网络适配器.虚拟机可通过主机网络适配器连接到主机系统所用的 LAN.桥接模式网络连接支持有线和无线主机网络适配器. ...
- spring-mvc 系列:视图(ThymeleafView、InternalResourceView、RedirectView)
目录 一.ThymeleafView 二.转发视图 三.重定向视图 四.视图控制器view-controller 五.配置jsp解析 SpringMVC中的视图是View接口,视图的作用渲染数据,将模 ...
- 知识图谱(Knowledge Graph)- Neo4j 5.10.0 Desktop & GraphXR 连接自建数据库
#输入查看数据库连接 neo4j$ :server status 添加 远程连接,输入连接地址 Graph Apps 选择 GraphXR 打开 显示
- 《最新出炉》系列初窥篇-Python+Playwright自动化测试-12-playwright操作iframe-中篇
1.简介 按照计划今天就要用实际的例子进行iframe自动化测试.经过宏哥长时间的查找,终于找到了一个含有iframe的网页(QQ邮箱和163邮箱),别的邮箱宏哥就没有细看了.所以今天这一篇的主要内容 ...
- python 获取本周 ,上周,本月,上月,本季,上季,今年, 去年的第一天和最后一天
import datetime from datetime import timedelta now = datetime.datetime.now()# 获取当前月的天数 month = 2days ...
- 2.4 PE结构:节表详细解析
节表(Section Table)是Windows PE/COFF格式的可执行文件中一个非常重要的数据结构,它记录了各个代码段.数据段.资源段.重定向表等在文件中的位置和大小信息,是操作系统加载文件时 ...
- 【译】在 Visual Studio 2022 中安全地在 HTTP 请求中使用机密
在 Visual Studio 2022 的17.8 Preview 1版本中,我们更新了 HTTP 文件编辑器,使您能够外部化变量,从而使跨不同环境的 Web API 测试更容易.此更新还包括以安全 ...
- 解决Nginx SSL 代理 Tomcat 获取 Scheme 总是 Http 问题
背景 公司之前用的是http,但是出于苹果app审核和服务器安全性问题,要改为https,我们公司用的是沃通的ssl,按照沃通的官方文档提供的步骤完成服务器的配置. 架构上使用了 Nginx +tom ...