Codeforces Round 995 (Div. 3)

QT开发串口程序与单片机通讯 如果有对象对这个信号感兴趣,想要处理的信号和自己的一个函数(称为槽(slot))绑定来处理这个信号。的内容,虽然实现的功能很简单,但是QT上位机开发的步骤基本就是这些步骤,通过这个基础实例把这些套路摸透我们就可以接着进行后续更多QT程序地开发学习了。QWidget类:所有用户界面对象的基类,窗口部件是用户界面的一个基本单元,它从窗口系统接收鼠标,键盘和其他消息,并在屏幕上绘制自己。我们上面运行的上位机都是在Qt Creator中编译运行的,如果我们需要把编写好的可执行文件发送给别人使用的话还需要进行打包。 阅读详情

在这里插入图片描述

A. Preparing for the Olympiad

Monocarp and Stereocarp are preparing for the Olympiad. There are n n n days left until the Olympiad. On the i i i-th day, if Monocarp plans to practice, he will solve a i a_i ai​ problems. Similarly, if Stereocarp plans to practice on the same day, he will solve b i b_i bi​ problems.

Monocarp can train on any day he wants. However, Stereocarp watches Monocarp and follows a different schedule: if Monocarp trained on day i i i and KaTeX parse error: Expected 'EOF', got '&' at position 3: i &̲lt; n, then Stereocarp will train on day ( i + 1 ) (i+1) (i+1).

Monocarp wants to organize his training process in a way that the difference between the number of problems he solves and the number of problems Stereocarp solves is as large as possible. Formally, Monocarp wants to maximize the value of ( m − s ) (m-s) (m−s), where m m m is the number of problems he solves, and s s s is the number of problems Stereocarp solves. Help Monocarp determine the maximum possible difference in the number of solved problems between them.

Input

The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 3 1 \le t \le 10^3 1≤t≤103) — the number of test cases.

The first line of each test case contains a single integer n n n ( 1 ≤ n ≤ 100 1 \le n \le 100 1≤n≤100).

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1​,a2​,…,an​ ( 1 ≤ a i ≤ 100 1 \le a_i \le 100 1≤ai​≤100).

The third line contains n n n integers b 1 , b 2 , … , b n b_1, b_2, \dots, b_n b1​,b2​,…,bn​ ( 1 ≤ b i ≤ 100 1 \le b_i \le 100 1≤bi​≤100).

Output

For each test case, print a single integer — the maximum possible difference between the number of problems Monocarp solves and the number of problems Stereocarp solves.

解题思路及AC代码

签到题

#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
void solve(){
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0;i < n;i ++){
		cin >> a[i];
	}
	for(int i = 0;i < n;i ++){
		cin >> b[i];
	}
	int ans = a[n - 1];
	for(int i = 0;i < n - 1;i ++){
		if(a[i] > b[i + 1]){
			ans += (a[i] - b[i + 1]);
		}
	}
	cout << ans << "\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
	cin >> t;
	
	while(t --){
		solve();
	}
}

B. Journey

Monocarp decided to embark on a long hiking journey.

He decided that on the first day he would walk a a a kilometers, on the second day he would walk b b b kilometers, on the third day he would walk c c c kilometers, on the fourth day, just like on the first, he would walk a a a kilometers, on the fifth day, just like on the second, he would walk b b b kilometers, on the sixth day, just like on the third, he would walk c c c kilometers, and so on.

Monocarp will complete his journey on the day when he has walked at least n n n kilometers in total. Your task is to determine the day on which Monocarp will complete his journey.

Input

The first line contains one integer t t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1≤t≤104) — the number of test cases.

Each test case consists of one line containing four integers n n n, a a a, b b b, c c c ( 1 ≤ n ≤ 1 0 9 1 \le n \le 10^9 1≤n≤109; 1 ≤ a , b , c ≤ 1 0 6 1 \le a, b, c \le 10^6 1≤a,b,c≤106).

Output

For each test case, output one integer — the day on which Monocarp will have walked at least n n n kilometers in total and will complete his journey.

解题思路及AC代码

签到题

#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
void solve(){
	int n,a,b,c;
	cin >> n >> a >> b >> c;
	int res = a + b + c;
	int cnt = n / res;
	cnt *= 3;
	n %= res;
	if(n){
		n -= a;
		cnt ++;
	}
	if(n > 0){
		n -= b;
		cnt ++;
	}
	if(n > 0){
		n -= c;
		cnt ++;
	}
	cout << cnt << "\n";
	
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
	cin >> t;
	
	while(t --){
		solve();
	}
}

C. Preparing for the Exam

Monocarp is preparing for his first exam at the university. There are n n n different questions which can be asked during the exam, numbered from 1 1 1 to n n n. There are m m m different lists of questions; each list consists of exactly n − 1 n-1 n−1 different questions. Each list i i i is characterized by one integer a i a_i ai​, which is the index of the only question which is not present in the i i i-th list. For example, if n = 4 n = 4 n=4 and a i = 3 a_i = 3 ai​=3, the i i i-th list contains questions [ 1 , 2 , 4 ] [1, 2, 4] [1,2,4].

During the exam, Monocarp will receive one of these m m m lists of questions. Then, the professor will make Monocarp answer all questions from the list. So, Monocarp will pass only if he knows all questions from the list.

Monocarp knows the answers for k k k questions q 1 , q 2 , … , q k q_1, q_2, \dots, q_k q1​,q2​,…,qk​. For each list, determine if Monocarp will pass the exam if he receives that list.

Input

The first line contains one integer t t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1≤t≤104) — the number of test cases.

Each test case consists of three lines:

  • the first line contains three integers n n n, m m m and k k k ( 2 ≤ n ≤ 3 ⋅ 1 0 5 2 \le n \le 3 \cdot 10^5 2≤n≤3⋅105; 1 ≤ m , k ≤ n 1 \le m, k \le n 1≤m,k≤n);
  • the second line contains m m m distinct integers a 1 , a 2 , … , a m a_1, a_2, \dots, a_m a1​,a2​,…,am​ ( 1 ≤ a i ≤ n 1 \le a_i \le n 1≤ai​≤n; KaTeX parse error: Expected 'EOF', got '&' at position 5: a_i &̲lt; a_{i+1});
  • the third line contains k k k distinct integers q 1 , q 2 , … , q k q_1, q_2, \dots, q_k q1​,q2​,…,qk​ ( 1 ≤ q i ≤ n 1 \le q_i \le n 1≤qi​≤n; KaTeX parse error: Expected 'EOF', got '&' at position 5: q_i &̲lt; q_{i+1}).

Additional constraints on the input:

  • the sum of n n n over all test cases does not exceed 3 ⋅ 1 0 5 3 \cdot 10^5 3⋅105.

Output

For each test case, print a string of m m m characters. The i i i-th character should be 1 if Monocarp passes the exam if he receives the i i i-th question list, 0 if Monocarp won’t pass.

解题思路及AC代码

简单构造

#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
void solve(){
	int n,m,k;
	cin >> n >> m >> k;
	vector<int> a(m),b(n);
	for(int i = 0;i < m;i ++){
		cin >> a[i];
	}
	int cnt = n - k;
	for(int i = 0;i < k;i ++){
		int x;
		cin >> x;
		x --;
		b[x] = 1;
	}
	for(int i = 0;i < m;i ++){
		a[i] --;
		if((!b[a[i]] && cnt == 1) || cnt == 0){
			cout << "1";
		}else{
			cout << "0";
		}
	}
	cout << "\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
	cin >> t;
	
	while(t --){
		solve();
	}
}

D. Counting Pairs

You are given a sequence a a a, consisting of n n n integers, where the i i i-th element of the sequence is equal to a i a_i ai​. You are also given two integers x x x and y y y ( x ≤ y x \le y x≤y).

A pair of integers ( i , j ) (i, j) (i,j) is considered interesting if the following conditions are met:

  • KaTeX parse error: Expected 'EOF', got '&' at position 9: 1 \le i &̲lt; j \le n;
  • if you simultaneously remove the elements at positions i i i and j j j from the sequence a a a, the sum of the remaining elements is at least x x x and at most y y y.

Your task is to determine the number of interesting pairs of integers for the given sequence a a a.

Input

The first line contains one integer t t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1≤t≤104) — the number of test cases.

Each test case consists of two lines:

  • The first line contains three integers n , x , y n, x, y n,x,y ( 3 ≤ n ≤ 2 ⋅ 1 0 5 3 \le n \le 2 \cdot 10^5 3≤n≤2⋅105, 1 ≤ x ≤ y ≤ 2 ⋅ 1 0 14 1 \le x \le y \le 2 \cdot 10^{14} 1≤x≤y≤2⋅1014);
  • The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1​,a2​,…,an​ ( 1 ≤ a i ≤ 1 0 9 1 \le a_i \le 10^{9} 1≤ai​≤109).

Additional constraint on the input: the sum of n n n across all test cases does not exceed 2 ⋅ 1 0 5 2 \cdot 10^5 2⋅105.

Output

For each test case, output one integer — the number of interesting pairs of integers for the given sequence a a a.

解题思路及AC代码

二分找到x,y的边界值,建议使用STL中的lower_bound,不然边界问题很容易出问题,我这里就是手写的二分调了半天。

#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
void solve(){
	int n,x,y;
	cin >> n >> x >> y;
	int ans = 0;
	vector<int> a(n + 1);
	int sum = 0;
	for(int i = 1;i <= n;i ++){
		cin >> a[i];
		sum += a[i];
	}
//	cout << sum << "\n";
	sort(a.begin() + 1,a.end());
	for(int i = 1;i < n;i ++){
		int res = sum;
		res -= a[i];
		if(res <= x){
			continue;
		}
		int l = i + 1,r = n;
		while(l < r){
			int mid = l + r + 1 >> 1;
			res -= a[mid];
			if(res < x){
				r = mid - 1;
			}else{
				l = mid;
			}
			res += a[mid];
		}
		res = sum - a[i];
		int l1 = i + 1,r1 = n;
		while(l1 < r1){
			int mid = l1 + r1 >> 1;
			res -= a[mid];
			if(res > y){
				l1 = mid + 1;
			}else{
				r1 = mid;
			}
			res += a[mid];
		}	
//		cout << l << " " << l1 << "\n";
		if(l > l1 || (l == l1 && res - a[l] >= x && res - a[l] <= y))
			ans += abs(l - l1) + 1;
	}
	cout << ans << "\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
	cin >> t;
	
	while(t --){
		solve();
	}
}

【Java基础知识 1】Java入门级概述 CSDN最强Java专栏,包含全部Java基础知识点、Java8新特性、Java集合、Java多线程、Java代码实例,理论结合实战,实现Java的轻松学习。 阅读详情

相关推荐

Ansys Maxwell磁场仿真入门:无线传能线圈自感与互感计算全流程

本文详细介绍了使用Ansys Maxwell进行无线充电线圈磁场仿真的全流程,包括模型建立、求解器设置、电感参数提取及优化策略。通过实战案例,帮助工程师掌握线圈自感与互感计算技巧,提升无线充电系统设计效率与精度。重点解析了Maxwell在磁场仿真中的关键应用,适用于电磁场仿真初学者和进阶用户。

weixin_29047545的博客 444

Codeforces Round 995 (Div. 3)(A~F题解)

不要问为什么没有G,因为G我还没搞明白,我是蒟蒻,补药降维打击窝。

2301_80475191的博客 2480

经典算法之——解决全排列问题以及详解

回溯”指的是“状态重置”,可以理解为“恢复现场”,是在编码的过程中,是为了节约空间而使用的,而在递归或者深度优先中根据需要的场合来配合回溯法可以进一步对自己的代码进行优化。, n-1, n},方向都为向左。邻位对换法是全排列生成算法中的其中一种,它的换位是双向的,通过保存数字的“方向性”来快速得到下一个排列。最后以 3 开头的全排列为[3, 1, 2], [3, 2, 1];以 1 开头的全排列为[1, 2, 3], [1, 3, 2];以 2 开头的全排列为[2, 1, 3], [2, 3, 1];

m0_68987535的博客 8796

Codeforces Round 995 (Div.3)

CF995 (A-G)

djhws144的博客 1228

AD/Protel老手才知道的PCB过孔查看技巧:3分钟分清通孔、盲孔和埋孔

本文为PCB设计工程师提供了在Altium Designer/Protel中快速鉴别通孔、盲孔和埋孔的实用技巧。通过层叠管理器、高级筛选工具和实战五步法,帮助用户在3分钟内精准识别过孔类型,提升设计效率和电路性能。特别适合处理高密度HDI板卡中的复杂过孔布局。

weixin_29164497的博客 587

Langchain与Milvus集成中的pymilvus.exceptions.MilvusException: channel not found错误解析

本文深入解析了在Langchain与Milvus集成时常见的pymilvus.exceptions.MilvusException: channel not found错误。该错误通常由客户端配置错误、网络问题、服务端状态异常或版本不兼容导致。文章提供了从基础连通性测试到高级网络排查的完整故障排除指南,并针对本地Docker、远程服务器及Kubernetes等典型部署场景给出了具体解决方案,帮助开发者快速定位并修复这一连接层问题。

weixin_29229989的博客 218

Codeforces Round 988 (Div. 3) (A - E)

对于 111001而言, 他们的前缀和分别为000002,即最后一个1能构成2个'01'就是前面'0'的个数,其余的位置为'1',即pos - w - 1个‘1’;其中pos表示第一个0后面的1的位置,w表示此处能构造'01'的个数;求取得增加能量得次数尽可能的少,因此需要每一次尽可能取最大的能量值;长度为 n 的数组当中,需要除掉2个数(n,m), 因此。对于 11100 而言,他们所有的前缀和为 0;,我们也可以判断,即前缀和不是0的第一个位置的。要找的字符串的长度为 2 ,我们需要。

LTphy的博客 1411

解决WSL2网络隔离:Ubuntu子系统共享Windows代理的3种方法

本文详细解析了WSL2的网络隔离特性,并提供了三种在Ubuntu子系统中共享Windows代理的实用方法:环境变量法、配置文件法和系统服务法。通过具体代码示例和方案对比,帮助开发者快速解决WSL2网络访问问题,实现一键设置代理,提升开发效率。

weixin_29295541的博客 454

Codeforces Round 995 (Div. 3) (A-D)

995(a-d)题解

2301_80078630的博客 756

LabVIEW电压信号采集系统:从零搭建到科研实战

本文详细介绍了如何从零开始搭建一个基于LabVIEW的电压信号采集系统。内容涵盖硬件选型(如NI USB-6002数据采集卡)、软件环境配置、核心程序开发(包括多通道同步采集、数据自动保存)以及高级功能优化。系统支持自定义采样率与时长,并提供了完整的LabVIEW程序框图和配套的Python数据分析脚本,旨在帮助科研人员和工程师快速构建稳定、高效的专属数据采集方案,提升实验自动化水平。

gold8的专栏 464

2026年全国青少年信息素养大赛复赛真题(算法应用主题赛C++小学组:带解析)(7月4日试卷一)【文末附答案和解析】

2026年全国青少年信息素养大赛复赛真题(算法应用主题赛C++小学组:带解析)(7月4日试卷一)【文末附答案和解析】

王老师青少年编程 1750

Codeforces Round 995 (Div. 3) C&D题解

题目链接C题Monocarp正在为他的大学第一场考试做准备。考试期间可能会问到n个不同的问题,编号为1到n。有m个不同的问题列表,每个列表恰好包含n-1个不同的问题。每个列表i用一个整数ai来表示,ai是该列表中未出现的唯一问题的索引。例如,如果n=4且ai=3,则第i个列表包含问题[1, 2, 4]。在考试期间,Monocarp将收到这m个问题列表中的一个。然后,教授会让Monocarp回答列表中的所有问题。因此,如果Monocarp知道列表中的所有问题,他才能通过考试。

2401_87211086的博客 1514

WebRTC之beamforming算法

CSND已永久停更,最新版唯一来源点击下面链接跳转: 语音增强和语音识别网页书 坐标问题 这里以笔记本为例进行说明,当笔记本按如下方式打开: 首先是键盘和液晶屏呈90度,然后鼠标上方,也就是液晶屏上方正中间是camera,把平行于键盘的面看成是xy平面,把液晶屏所在的面看成是xz平面,所有平面的原点都在Camera的位置。 方位角:从原点开始,Camera的右侧是0度,逆时针方...

shichaog的专栏 1万+

Codeforces Round 995 (Div. 3)(A-E)

Codeforces Round 995 (Div. 3)

Vcoistnt的博客 658

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Codeforces Round 995 (Div. 3)个人题解 (A-G)

Codeforces Round 995 (Div. 3)个人题解 (A-G)

FZANOTFOUND的博客 1241

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

codeforces round 995

codeforces round 995

青少年趣味编程 1954

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Codeforces Round 995 (Div. 3)【题解】D ~ G

Codeforces Round 995 (Div. 3)【题解】,D.Counting Pairs,E.Best Price,F.Joker,G. Snakes

2401_88501775的博客 1568

Codeforces Round 995 (Div. 3)C~E

找到满足条件的a[j]即可,先进行排序,使整个数组单调,再枚举每个a[i],再通过二分找到a[j]的左右边界位置,这里可以直接使用lower_bound(a.begin()+i,a.end(),sum-x)找到左边界,再通过upper_bpound(b.begin()+i,b.end(),sum-y)找到右边界,这里右边界使用upper的是因为如果出现一个数是满足的但是这个数出现了多次,用lower会导致到第一个数就停下了,所以用upper去避免这个问题,之后再把右边界往左边移一个位置就ok了。

2301_82092165的博客 836

Codeforces Round 995 (Div. 3) DE

排一下序,由于每一个数对都是唯一的,所以排完序后的数对数量不会改变,此时遍历数组,对每个元素,二分查找一个区间,这个过程一定是单调的,复杂度O(nlogn)

zeisenphael的博客 471

Codeforces Round 995 (Div. 3) D. Counting Pairs

第一行包含三个整数n,x,y(3≤n≤2⋅10^5,1≤x≤y≤2⋅10^14);输入的额外约束:所有测试用例中n的总和不超过2⋅10^5。每个测试的时间限制为2秒 每个测试的内存限制为256兆字节 给定一个由n个整数组成的序列a,其中序列的第i个元素等于ai。如果同时从序列a中移除位置i和j的元素,剩余元素的和至少为x且至多为y。输出 对于每个测试用例,输出一个整数——给定序列a中有趣整数对的数量。输入 第一行包含一个整数t(1≤t≤10^4)——测试用例的数量。

Ljh33529300的博客 696

Codeforces Round 935

Codeforces Round 935

青少年趣味编程 674

本人 debug 惨痛的教训

你的任务是在商店最多只能收到 k 条负面评价的情况下,计算商店的最大可能收入。输入 第一行包含一个整数 t (1≤t≤10⁴)——测试用例的数量。每个测试用例的第一行包含两个整数 n 和 k (1≤n≤2⋅10⁵;输入的额外约束:所有测试用例中 n 的总和不超过 2⋅10⁵。输出 对于每个测试用例,打印一个整数——在商店最多只能收到 k 条负面评价的情况下,商店的最大可能收入。在开始销售之前,商店需要确定一棵树的价格(所有顾客的价格相同)。否则,如果产品的价格不超过 bi,顾客会购买一棵树但留下负面评价;

Ljh33529300的博客 226
上一篇: 2024“钉耙编程”中国大学生算法设计超级联赛(8)
下一篇: 《计算机网络A》单选题-复习题库
陈童学哦
陈童学哦 优质创作者: 算法与数据结构技术领域 优质创作者: 算法与数据结构技术领域
博客等级 码龄4年 3万+粉丝 184原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈童学哦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址