School training competition ( Second )
A. Medium Number
链接 : Problem - 1760A - Codeforces

就是求三个数的中位数 :
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;inline void solve(){int a[3];for(int i=0;i<3;i++) cin >> a[i];sort(a,a+3);cout << a[1] << endl;
}int main()
{IOSint _ = 1;cin >> _;while(_ --) solve();return 0;
}
B. Atilla's Favorite Problem

就是求最大字母的长度 (与a的距离)
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;int n ;
string s;inline void solve(){cin >> n ;cin >> s;sort(s.begin(),s.end());int ans = (int)(s[n-1]-'a'+1);cout << ans << endl;
}int main()
{IOSint _ = 1;cin >> _;while(_ --) solve();return 0;
}
C. Advantage
链接 : Problem - 1760C - Codeforces

数据范围小的话,随便弄,直接排序之后,求出最大和第二大的值,然后遍历i,求a[i]与除a[i]之外最大值的差距。
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;int n ;inline void solve(){cin >> n;vector<int> a(n),b(n);for(int i=0;i<n;i++){cin >> b[i];a[i] = b[i];}sort(b.begin(),b.end());int ma = b[n-1] , mi = b[n-2];for(int i=0;i<n;i++){if(a[i] != ma) cout << a[i] - ma << " ";else cout << a[i] - mi << " ";}cout << endl;
}int main()
{IOSint _ = 1;cin >> _;while(_ --) solve();return 0;
}
D. Challenging Valleys
链接 : Problem - 1760D - Codeforces


题目大概就是说 给出一个数组,如果该数组有且仅有 一个山谷形状的子数组,就输出yes,否则返回false;
这题直接模拟就可以了
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;int n;
int a[N],b[N];inline void solve(){cin >> n;for(int i=0;i<n;i++) cin >> b[i];if(n==1){cout << "YES" << endl;return ; }int len = n;n = 0;a[n++] = b[0];//把连续的数去重for (int i = 1; i < len; ++i) {if (b[i] != b[i - 1])a[n++] = b[i];}int cnt = 0;if(n==1 || n==2){cout << "YES" << endl;return ;}if(a[1]>a[0]) cnt ++;if(a[n-2] > a[n-1]) cnt ++;for(int i=1;i<n-1;i++){if(a[i-1]>a[i] && a[i] < a[i+1]){cnt ++;}}if(cnt == 1) cout << "YES" << endl;else cout << "NO" << endl;return ;
}int main()
{IOSint _ = 1;cin >> _;while(_ --) solve();return 0;
}
E. Binary Inversions
链接 : Problem - 1760E - Codeforces

思路 : 要求逆序对的数量最大,那么也就只有三种情况,不改 / 将第一个0改为1 / 将最后的1转换为0, 三种情况分情况讨论即可;
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;inline void solve(){int n ; cin >> n;LL ans = 0 , res = 0;vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];int pre = 0;for(int i=n-1;i>=0;i--){if(a[i]==0) pre++;else ans += pre; // 预处理每个 1 后面 有 多少个 0 之和 }pre = 0;int t = -1;for(int i=0;i<n;i++){if(a[i]==0){// 将第一个 0 转换为 1 t = i;a[i]=1;break;}}for(int i=n-1;i>=0;i--){if(a[i]==0) pre++;else res += pre;}ans = max(ans,res);if(t!=-1) a[t] = 0;res = 0;pre = 0;for(int i=n-1;i>=0;i--){if(a[i]==1){ // 将最后的 1 转换为 0 a[i]=0;break;}}for(int i=n-1;i>=0;i--){if(a[i]==0) pre++;else res += pre;}cout << max(res,ans) << endl;return ;
}int main()
{IOSint _ = 1;cin >> _;while(_ --) solve();return 0;
}
F. Quests
链接 : Problem - 1760F - Codeforces

思路 : 二分求 k 值
/**
* ┏┓ ┏┓
* ┏┛┻━━━┛┻┓
* ┃ ┃
* ┃ ━ ┃
* ████━████
* ◥██◤ ◥██◤
* ┃ ┻ ┃
* ┃ ┃
* ┗━┓ Y ┏━┛
* ┃ S ┃
* ┃ S ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*/#include<bits/stdc++.h>
using namespace std;#define int long long
int n,c,d;
int T;
int a[1000050];inline bool check(int k){int now = 1;int res = 0;for(int i=1;i<=d;++i){res+=a[now];++now;if(now == k+2){now = 1;}if(now == n +1){i += k + 1 - n;now = 1;}}return res >= c;
}signed main()
{cin >> T ;while(T--) {cin >> n >> c >> d;for(int i=1; i<=n; ++i) cin >> a[i] ;int sum = 0;sort(a+1,a+n+1);reverse(a+1,a+n+1);bool f = 0;if(a[1] * d < c){puts("Impossible");continue;}if(d <= n){sum = 0;for(int i=1;i<=d;++i){sum+=a[i];}if(sum >= c){f = 1;}}if(f){puts("Infinity");continue;}int res = 0;int l =0;int r =1e16+1;while(l<=r){int mid = l + r >> 1;if(check(mid)){res = mid;l = mid + 1;}else{r = mid - 1;}}if(res == 1e16 + 1){puts("Infinity");continue;}cout<<res<<endl;}return 0;
}
A - Filter
链接 : A - Filter

直接模拟就行了
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 2e5+10;inline void solve(){int n ; cin >> n;for(int i=0;i<n;i++){int x ; cin >> x;if(x %2 ==0){cout << x << " ";}}
}int main()
{IOSint _ = 1;// cin >> _;while(_ --) solve();return 0;
}
B - ASCII Art
链接 : B - ASCII Art

也是水题,直接模拟输出即可
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 110;int a[N][N];
char s[N][N];inline void solve(){int n,m ;cin >> n >> m;for(int i=0;i<n;i++)for(int j = 0;j<m;j++)cin >> a[i][j];for(int i=0;i<n;i++)for(int j = 0;j<m;j++){if(a[i][j] == 0) s[i][j] = '.';else s[i][j] = (char)('A'+a[i][j]-1);}for(int i=0;i<n;i++){for(int j = 0;j<m;j++){cout << s[i][j]; }cout << endl;}
}int main()
{IOSint _ = 1;// cin >> _;while(_ --) solve();return 0;
}
C - Merge Sequences
链接 : C - Merge Sequences

题意大概是合并两个升序排列的数组,然后求a,b两个数组的元素在新数组中的下标是多少:
这一题直接模拟合并过程即可,在合并的过程中将对应的下标分别添加到ca,cb两个数组中;
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;const int N = 1e5+10;
int a[N],b[N];int n,m;inline void solve(){cin >> n >> m;for(int i=1;i<=n;i++) cin >> a[i];for(int i=1;i<=m;i++) cin >> b[i];// a , b 递增 vector<int> ca,cb; int k = 1 ;int p1 = 1 , p2 = 1;while(p1 <= n || p2 <= m){if(p1 == n+1){cb.push_back(k++);p2++;}else if(p2 == m+1){ca.push_back(k++);p1++;}else if(a[p1] < b[p2]){ca.push_back(k++);p1++;}else{cb.push_back(k++);p2++;}}for(int x : ca) cout << x << " ";cout << endl;for(int x : cb) cout << x << " ";cout << endl;
}int main()
{IOSint _ = 1;// cin >> _;while(_ --) solve();return 0;
}
D - Bank
链接 : D - Bank

思路 : 模拟
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 5e5+10;int n,q;
int t,x;
bool a[N] = {false}; // 标记 是不是已经 go inline void solve(){cin >> n >> q;int cnt = 1 , now = 1;while(q--){cin >> t;if(t==1){cnt ++;}else if(t==2){cin >> x;// 叫到就一定来了 a[x] = true;}else{while(a[now]) ++now;cout << now << endl;}}
}int main()
{IOSint _ = 1;// cin >> _;while(_ --) solve();return 0;
}
E - 2xN Grid
链接 : E - 2xN Grid


思路 : 也是模拟 , 一一对应即可,和 C 题类似
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'using namespace std;
typedef long long LL;
const int N = 1e5+10;LL l,n,m;
LL v1[N],len1[N];//值 和 个数
LL v2[N],len2[N];inline void solve(){cin >> l >> n >> m;for(int i=1;i<=n;i++) cin >> v1[i] >> len1[i];for(int i=1;i<=m;i++) cin >> v2[i] >> len2[i];LL ans = 0;int a = 1 , b = 1;while(a <= n && b <= m){if(v1[a] == v2[b]) ans += min(len1[a] , len2[b]);if(len1[a] < len2[b]){len2[b] -= len1[a];a++;}else{len1[a] -= len2[b];b++;}}cout << ans << endl;
}int main()
{IOSint _ = 1;// cin >> _;while(_ --) solve();return 0;
}
相关文章:
School training competition ( Second )
A. Medium Number 链接 : Problem - 1760A - Codeforces 就是求三个数的中位数 : #include<bits/stdc.h> #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl \nusing namespace std; typedef long long LL; const int N 2e510;inline void …...
深度解析 Docker Registry:构建安全高效的私有镜像仓库
文章目录 什么是Docker Registry?Docker Hub vs. 私有RegistryDocker Hub:私有Registry: 如何构建私有Docker Registry?步骤一:安装Docker Registry步骤二:配置TLS(可选)步骤三&…...
leetcode 不同的二叉搜索树
给你一个整数 n ,求恰由 n 个节点组成且节点值从 1 到 n 互不相同的 二叉搜索树 有多少种?返回满足题意的二叉搜索树的种数。 示例 1: 输入:n 3 输出:5 示例 2: 输入:n 1 输出:…...
通俗易懂的spring Cloud;业务场景介绍 二、Spring Cloud核心组件:Eureka 、Feign、Ribbon、Hystrix、zuul
文章目录 通俗易懂的spring Cloud一、业务场景介绍二、Spring Cloud核心组件:Eureka三、Spring Cloud核心组件:Feign四、Spring Cloud核心组件:Ribbon五、Spring Cloud核心组件:Hystrix六、Spring Cloud核心组件:Zuul七…...
大数据预处理技术
文章目录 前言 大数据技术成为前沿专业 也是现在甚至未来的朝阳产业,大数据有分别是 数据预处理 数据存储 大数据处理和分析 数据可视化 部分组成 ,大数据行业有数据则称王,大数据的核心是数据本身 怎么获取有价值的数据呢?本章讲…...
跳表的学习记录
跳表(Skip List)是一种数据结构,它通过在多个层次上添加额外的前向指针来提高有序数据的搜索效率。跳表与其他常见的有序数据结构(如二叉搜索树、平衡树如AVL树和红黑树、B树等)相比,具有其独特的优缺点&am…...
电子学会C/C++编程等级考试2022年09月(二级)真题解析
C/C++等级考试(1~8级)全部真题・点这里 第1题:统计误差范围内的数 统计一个整数序列中与指定数字m误差范围小于等于X的数的个数。 时间限制:5000 内存限制:65536输入 输入包含三行: 第一行为N,表示整数序列的长度(N <= 100); 第二行为N个整数,整数之间以一个空格分…...
如何使用nginx部署静态资源
Nginx可以作为静态web服务器来部署静态资源,这个静态资源是指在服务端真实存在,并且能够直接展示的一些文件数据,比如常见的静态资源有html页面、css文件、js文件、图片、视频、音频等资源相对于Tomcat服务器来说,Nginx处理静态资…...
lua的gc原理
lua垃圾回收(Garbage Collect)是lua中一个比较重要的部分。由于lua源码版本变迁,目前大多数有关这个方面的文章都还是基于lua5.1版本,有一定的滞后性。因此本文通过参考当前的5.3.4版本的Lua源码,希望对Lua的GC算法有一个较为详尽的探讨。 L…...
redis作为缓存详解
目录 前言: 为什么说关系型数据库性能不高 如何提高MySQL并发量 缓存更新策略 定期更新 实时更新 内存淘汰策略 Redis内置的淘汰策略 缓存常见问题 缓存预热 缓存穿透 缓存雪崩 缓存击穿 前言: 对于缓存的理解,缓存目的就是为了…...
231127 刷题日报
这周值班。。多少写道题吧,保持每天的手感。老婆给买了lubuladong纸质书,加油卷。 1. 131. 分割回文串 写个这个吧,钉在耻辱柱上的题。 为啥没写出来: 1. 递归树没画对 把树枝只看做是1个字母,而且不清楚树枝和节点…...
【Linux】vim-多模式的文本编辑器
本篇文章内容和干货较多,希望对大家有所帮助👍 目录 一、vim的介绍 1.1 vi 与 vim的概念1.2 Vim 和 Vi 的一些对比 二、vim 模式之间的切换 2.1 进入vim2.2 [正常模式]切换到[插入模式]2.3 [插入模式]切换至[正常模式]2.4 [正常模式]切换至[底行模式…...
Ubuntu 启用 root 用户
在启用 root 用户之前,我们先来了解一下, ubuntu 命令的组成。 打开 ubuntu 的终端,现在的命令行是由 topeetubuntu:~$ 这几个字母组成,那么这几个字母都代表 什么意思呢? topeet …...
手摸手Element-ui路由VueRoute
后端WebAPI准备 https://router.vuejs.org/zh/guide/ https://v3.router.vuejs.org/zh/installation.html <template><el-table:data"tableData"style"width: 100%":row-class-name"tableRowClassName"><!-- <el-table-colum…...
探究Kafka原理-5.Kafka设计原理和生产者原理解析
👏作者简介:大家好,我是爱吃芝士的土豆倪,24届校招生Java选手,很高兴认识大家📕系列专栏:Spring源码、JUC源码、Kafka原理🔥如果感觉博主的文章还不错的话,请ὄ…...
浅谈C#在unity应用中的工厂模式
文章目录 前言简单工厂模式工厂方法模式抽象工厂模式Unity实战 前言 工厂模式是一种创建型设计模式,它提供了一种将对象的实例化过程封装起来的方法,使得客户端代码不必直接依赖于具体类。这有助于降低代码的耦合度,提高代码的可维护性和可扩…...
卷积神经网络(Inception-ResNet-v2)交通标志识别
文章目录 一、前言二、前期工作1. 设置GPU(如果使用的是CPU可以忽略这步)2. 导入数据3. 查看数据 二、构建一个tf.data.Dataset1.加载数据2. 配置数据集 三、构建Inception-ResNet-v2网络1.自己搭建2.官方模型 五、设置动态学习率六、训练模型七、模型评…...
网易云音频数据如何爬取?
在当今数字化时代,音频数据的获取和处理变得越来越重要。本文将详细介绍如何使用Objective-C语言构建音频爬虫程序,以爬取网易云音乐为案例。我们将从Objective-C的基础知识开始,逐步深入到爬取思路分析、构建爬虫框架、完整爬取代码等方面&a…...
97、Text2NeRF: Text-Driven 3D Scene Generation with Neural Radiance Fields
简介 论文地址 使用扩散模型来推断文本相关图像作为内容先验,并使用单目深度估计方法来提供几何先验,并引入了一种渐进的场景绘制和更新策略,保证不同视图之间纹理和几何的一致性 实现流程 简单而言: 文本-图片扩散模型生成一…...
【C++】多态(上) 多态 | 虚函数 | 重写 | final、override | 接口继承与实现继承 | 抽象类
一、多态 概念 多态,就是多种状态,即不同的对象去完成同一个行为时会产生出不同的状态。比如:买票时,成人要原价买,学生和老人就可以享受优惠价便宜一点儿。同样是买票这个行为,不同的对象来做就有不同的…...
零门槛NAS搭建:WinNAS如何让普通电脑秒变私有云?
一、核心优势:专为Windows用户设计的极简NAS WinNAS由深圳耘想存储科技开发,是一款收费低廉但功能全面的Windows NAS工具,主打“无学习成本部署” 。与其他NAS软件相比,其优势在于: 无需硬件改造:将任意W…...
stm32G473的flash模式是单bank还是双bank?
今天突然有人stm32G473的flash模式是单bank还是双bank?由于时间太久,我真忘记了。搜搜发现,还真有人和我一样。见下面的链接:https://shequ.stmicroelectronics.cn/forum.php?modviewthread&tid644563 根据STM32G4系列参考手…...
Qt Widget类解析与代码注释
#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码,写上注释 当然可以!这段代码是 Qt …...
使用 SymPy 进行向量和矩阵的高级操作
在科学计算和工程领域,向量和矩阵操作是解决问题的核心技能之一。Python 的 SymPy 库提供了强大的符号计算功能,能够高效地处理向量和矩阵的各种操作。本文将深入探讨如何使用 SymPy 进行向量和矩阵的创建、合并以及维度拓展等操作,并通过具体…...
WebRTC从入门到实践 - 零基础教程
WebRTC从入门到实践 - 零基础教程 目录 WebRTC简介 基础概念 工作原理 开发环境搭建 基础实践 三个实战案例 常见问题解答 1. WebRTC简介 1.1 什么是WebRTC? WebRTC(Web Real-Time Communication)是一个支持网页浏览器进行实时语音…...
基于鸿蒙(HarmonyOS5)的打车小程序
1. 开发环境准备 安装DevEco Studio (鸿蒙官方IDE)配置HarmonyOS SDK申请开发者账号和必要的API密钥 2. 项目结构设计 ├── entry │ ├── src │ │ ├── main │ │ │ ├── ets │ │ │ │ ├── pages │ │ │ │ │ ├── H…...
深度解析云存储:概念、架构与应用实践
在数据爆炸式增长的时代,传统本地存储因容量限制、管理复杂等问题,已难以满足企业和个人的需求。云存储凭借灵活扩展、便捷访问等特性,成为数据存储领域的主流解决方案。从个人照片备份到企业核心数据管理,云存储正重塑数据存储与…...
数据挖掘是什么?数据挖掘技术有哪些?
目录 一、数据挖掘是什么 二、常见的数据挖掘技术 1. 关联规则挖掘 2. 分类算法 3. 聚类分析 4. 回归分析 三、数据挖掘的应用领域 1. 商业领域 2. 医疗领域 3. 金融领域 4. 其他领域 四、数据挖掘面临的挑战和未来趋势 1. 面临的挑战 2. 未来趋势 五、总结 数据…...
2025年全国I卷数学压轴题解答
第19题第3问: b b b 使得存在 t t t, 对于任意的 x x x, 5 cos x − cos ( 5 x t ) < b 5\cos x-\cos(5xt)<b 5cosx−cos(5xt)<b, 求 b b b 的最小值. 解: b b b 的最小值 b m i n min t max x g ( x , t ) b_{min}\min_{t} \max_{x} g(x,t) bmi…...
Docker 镜像上传到 AWS ECR:从构建到推送的全流程
一、在 EC2 实例中安装 Docker(适用于 Amazon Linux 2) 步骤 1:连接到 EC2 实例 ssh -i your-key.pem ec2-useryour-ec2-public-ip步骤 2:安装 Docker sudo yum update -y sudo amazon-linux-extras enable docker sudo yum in…...
