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 ...
随机推荐
- Tauri-Admin通用后台管理系统|tauri+vue3+pinia桌面端后台EXE
基于tauri+vite4+pinia2跨端后台管理系统应用实例TauriAdmin. tauri-admin 基于最新跨端技术 Tauri Rust webview2 整合 Vite4 构建桌面端通 ...
- C语言基础-基础指针
文章目录 指针 前言 1.什么是指针 2.指针的使用 (1)指针的定义 (2)指针的赋值 (3)指针类型 (4)如何使用指针 3.野指针 (1)导致野指针的原因 ① 未初始化指针 ②指针越界访问 ③指 ...
- 轻松理解Java中的public、private、static和final
一.概念 1.public和private 两个都是访问权限修饰符,用于控制外界对类内部成员的访问. public:表明对象成员是完全共有的,外界可以随意访问.用public修饰的数据成员.成员函数是 ...
- Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream
伪 分布模式下启动spark报错 从spark1.4以后,所有spark的编译都是没有将hadoop的classpath编译进去的,所以必须在spark-env.sh中指定hadoop中的所有jar包 ...
- 创建本地yum仓库
创建本地yum仓库 1,将镜像挂载到/mnt 如果失败打开虚拟机把设备状态的两个选项打勾 2,切换到客户端的指定目录 3,创建文件夹bak存放网络yum创库配置文件 4,将网络源移动到bak减少干扰 ...
- 牛客小白月赛65 E题 题解
原题链接 题意描述 构造一个\(1\)到\(n\)的排列,使得其中正好有\(k\)个二元组\((i, j)\)满足,\(1\le i\lt j\le n\) && \(a_i - a_ ...
- Promise的理解和使用(二)
一.Promise的常用APIpromise的这些方法执行完成都会返回一个新的promise,promise的状态由执行的结果决定. (1) new Promise()中的excutor函数 new ...
- markdown之mermaid
官方文档 01 简单的流程图 TD或TB:top to bottom,从上到下的流程图 LR:从左到右 其它:RL,BT flowchart LR; A([节点A的圆矩框]) --> |AB之间 ...
- Health Kit基于数据提供专业方案,改善用户睡眠质量
什么是CBT-I? 中国社科院等机构今年发布的<中国睡眠研究报告2023>内容显示,2022年,受访者的每晚平均睡眠时长为7.40小时,近半数受访者的每晚平均睡眠时长不足8小时(47.55 ...
- 让 GPT-4 来修复 Golang “数据竞争”问题 - 每天5分钟玩转 GPT 编程系列(6)
目录 1. Golang 中的"数据竞争" 2. GoPool 中的数据竞争问题 3. 让 GPT-4 来修复数据竞争问题 3.1 和 GPT-4 的第一轮沟通 3.2 和 GPT ...