Codeforces Round #410 (Div. 2) D. Mike and distribution 思维

从零开始搭建水质监测系统:STM32+Lora+4G的物联网应用详解 本文详细介绍了如何从零开始搭建一个基于STM32、LoRa和4G技术的工业级水质监测物联网系统。文章深入剖析了系统架构设计、核心硬件选型(如STM32F103系列MCU)、关键电路接口、嵌入式软件驱动开发、多任务调度以及云端数据集成与可视化的完整实战流程,为智慧农业、环境监测等领域的物联网应用提供了宝贵的“避坑指南”和解决方案。 阅读详情

D. Mike and distribution
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length neach which he uses to ask people some quite peculiar questions.

To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. SequenceP will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to  because it will be to easy to find sequence P if he allowed you to select too many elements!

Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.

On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.

Output

On the first line output an integer k which represents the size of the found subset. k should be less or equal to .

On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.

Example
input
5
8 7 4 8 3
4 2 5 3 7
output
3
1 4 5

题意是给两个序列,让你选几个下标,使得对于这两个序列都满足所选的数和大于未选的数和

思维水题,先按a值从大到小排序,扫一遍,先取最大的那个值,然后两个两个的选,优先选b值较大的,如果总数为偶数个,则最后还会剩一个,选上就好了,这样不难想ab都会满足那个条件。

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define eps 1e-9
#define PI 3.141592653589793
#define bs 1000000007
#define bsize 256
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
using namespace std;
struct node
{
	int a,b,index;
}num[100005];
int cmp(node a,node b)
{
	return a.a>b.a;
}
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&num[i].a),num[i].index=i;
	for(i=1;i<=n;i++)
	scanf("%d",&num[i].b);
	sort(num+1,num+n+1,cmp);
	vector<int>ans;
	ans.push_back(num[1].index);
	for(i=2;i<=n;i+=2)
	{
		if(i+1<=n&&num[i+1].b>num[i].b)
		ans.push_back(num[i+1].index);
		else
		ans.push_back(num[i].index);
	}
	printf("%d\n",ans.size());
	for(i=0;i<ans.size();i++)
	printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
 }




14、PostgreSQL日志文件、系统统计与查询优化全解析 本文全面解析了PostgreSQL数据库中的系统统计、日志文件配置与查询优化技巧。详细介绍了如何利用pg_stat_statements模块进行性能监控,配置日志记录以发现潜在问题,并深入探讨了查询优化器的工作原理和优化策略。通过实际案例分析,展示了如何综合应用这些技术提升数据库性能。适合希望提升PostgreSQL性能与稳定性的数据库管理员和开发人员阅读。 阅读详情

相关推荐

从理论到实践:使用Sigrity SystemSI完成DDR4信号完整性仿真全流程解析

本文详细解析了使用Sigrity SystemSI完成DDR4信号完整性仿真的全流程,从核心挑战到实战操作。文章深入探讨了DDR4信号完整性问题,介绍了SystemSI工具链的演进与分工,并提供了从前期准备到高级技巧的详细指南,帮助工程师有效解决DDR4设计中的信号完整性问题。

weixin_30505225的博客 518

D. Mike and distribution

D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking abou

Accepted ALL lve 1087

RNA-Seq数据分析实战:从FastQC到STAR比对的完整流程(附避坑指南)

本文提供了RNA-Seq数据分析从FastQC质控到STAR比对的完整实战流程与避坑指南。详细解读了FastQC/MultiQC报告的关键指标,并重点阐述了STAR比对工具的核心参数设置、索引构建及性能优化策略,旨在帮助用户获得准确可靠的比对结果,为下游基因表达分析奠定坚实基础。

weixin_29290259的博客 95

CodeForces 798D Mike and distribution (贪心)

题意:给你长度为n的a、b两个数组,让你找到n/2+1个下标,使得两个数组中下标分别表示的数的和*2>数组各自的和。 题解:贪心 先对数组a进行降序排序。 那么对于奇数个元素,第一个必选,剩下的按顺序每两个任意选一个必然满足条件。对于偶数个元素,首尾必选,剩下的按顺序每两个任意选一个也必然满足条件。 接下来考虑数组b,只要在数组a任意二选一时,选择b中最大的即可。 注意边界。 #define _CRT_SECURE_NO_WARNINGS #include<iostream> #inclu

gongyuandaye的博客 221

(MIUI)小米手机录音文件深度寻踪:从系统缓存到数据目录的实战解析

本文深入解析了MIUI系统中录音文件丢失的常见原因及解决方案,包括系统升级兼容性问题、应用缓存机制异常和存储权限变动。通过实战操作指南,详细介绍了如何从系统目录、数据库层面恢复录音文件,并提供了预防措施和自动化备份方案,帮助小米手机用户有效找回重要录音数据。

weixin_42699679的博客 528

【一】Android MediaPlayer整体架构源码分析 -【初始化和创建】

本系列文章分析的安卓源码版本:【Android 10.0 版本】 一、MediaPlayer的简单调用关键流程 【这只是一个简单使用过程示例】 // 此处变量声明省略 private void play() { // 先获取SurfaceHolder mSurfaceView = findViewById(R.id.surface_view); mSurfaceHolder = mSurfaceView.getHolder(); mSurfac

CloverLHao的博客 4351

Codeforces 798D Mike and distribution (构造 + 脑洞 推荐)

Codeforces 798D Mike and distribution (构造 + 脑洞 推荐)

Tc的专栏 1003

Windows服务器XMRig挖矿病毒深度清除实战指南

XMRig是一种广泛用于Monero(XMR)加密货币挖矿的开源工具,其在Windows环境中的持久化机制已远超传统木马范畴,融合WMI事件订阅、服务伪装、PowerShell无文件执行与注册表隐写等多重反检测技术。理解其基于行为而非特征的生存逻辑,是实现有效检测与根除的前提。该技术具备强隐蔽性、高自愈性与网络通信合法化特征,常见于RDP弱口令爆破、SMB共享泄露及PowerShell远程执行等非漏洞类入侵场景。本文聚焦Windows原生命令与Sysinternals工具链,提供覆盖进程定位、WMI清理、服

weixin_30535843的博客 743

Codeforces 798D Mike and distribution (构造)

题目链接 http://codeforces.com/contest/798/problem/D 题解 前几天的模拟赛,居然出这种智商题。。被打爆了QAQ 这个的话,考虑只有一个序列怎么做,把所有的排序取最大的当然可以,但是还有一种做法,就是两两分组之后每两个相邻的取大的!! 于是按照\(a\)排序,先取第一个,后面每两个相邻的取b较大的。做完了! 哇这怎么想出来的啊。。。。 代码 #i...

weixin_30439131的博客 174

【Halcon 】Halcon 实战:如何为 XLD 模板添加极性信息以提升匹配精度?

本文介绍了Halcon中为XLD轮廓模板添加极性信息的实用技巧。通过先以"ignore_local_polarity"模式创建模板,首次匹配获得位置后,使用set_shape_model_metric运算符结合真实图像为模板注入极性信息(边缘明暗方向)。这种方法弥补了XLD模板初始不支持极性的缺陷,可显著提升后续匹配的精度和抗干扰能力。实验显示,添加极性信息后的模板匹配效果明显优于无极性的匹配结果。该技术特别适用于基于手动绘制或处理后的XLD轮廓创建模板的场景。

songhuangong123的博客 756

多天线技术:5G波束成形&空间复用&空时编码

以提升信号的可靠性。然而,在20世纪90年代中期,研究者们惊讶地发现,多天线技术不仅仅提供分集增益,还可以开启一些单天线系统无法实现的新机遇。,我们可以将信道矩阵 ( H ) 视为一个满秩矩阵,则理论上可以建立min(𝑁𝑇,𝑁𝑅)个独立的数据流,形成一个。波束成形是5G物理层的核心技术,其本质是利用多个天线来增强特定方向上的信号,同时抑制干扰方向的信号。:物理波束成形 = 🔦 类似手电筒的聚焦光束,虚拟波束成形 = 🌊 类似水波的相干叠加。随着 5G 和 6G 时代的到来,多天线技术的作用愈发重

weixin_43199439的博客 1394

Codeforces 798D Mike and distribution【思维+贪心】好题!好题!感觉智商受到了一万点伤害= =

D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking about the hars

mengxiang000000 1235

Sigrity System Explorer Transient Analysis模式进行瞬态仿真分析操作指导-单端信号-串联端接

Sigrity System Explorer Transient Analysis模式可以用于瞬态仿真分析,通过搭建简易拓扑用于前仿真分析通道的时域性能,下面搭建一个简易的单端拓扑并且进行串联端接,以下图为例,准备好发送接收端的IBIS模型, (se_example.ibs,本例发送接收端都使用相同的IBIS模型),以及传输线的S参数模型(W1_welement_se.sp)最上方的图形界面是传输线的模型,本例是一个上下都有参考平面的带状线,右侧的梯形是蚀刻角度,根据W1和W2以及铜厚来确定。

weixin_54787054的博客 340

Codeforces Round #410 (Div. 2) D. Mike and distribution 思维+数学

链接: http://codeforces.com/contest/798/problem/D 题意: 给你两个长度为n的数列a和b,让你选n/2+1个下标,使得2*∑ai&gt;suma,2*∑bi&gt;sumb 题解1: 用一个叫random_shuffle的东西,每次都乱选,然后暴力前n/2+1个。 这种做法真的是毫无人性啊。以后不会的就这么办吧 代码: ...

花海 100

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

【解题报告】Codeforces Round #410 (Div. 2)

简略的解题报告。

TRiddle的博客 1146

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Codeforces Round #410 Div2 D Mike and distribution

Mike has always been thinking about the harshness of social inequality. He’s so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of posi

且听风吟 529

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces Round #410 (Div. 2)(Codeforces 798 ABCD)

Codeforces Round #410 (Div. 2)菜的抠脚,只会做A题也是没谁了。。。 对着官方题解写了BCD 传送门:官方题解Codeforces 798A Mike and palindrome题意给你一个字符串,问你能否仅改变一个字符,使它成为一个回文串。注意必须改变一个字符,不能不变。思路水题,检查1到n/2中si ≠ sn - i + 1的个数,如果大于两个,那么NO; 如

P.H.S 356

Codeforces Round #410 (Div. 2) A B C D E

A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of on

J. Cole 501

Codeforces Round #410 (Div. 2) D. Mike and distribution

D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking abou

291

Codeforces Round #410 (Div. 2) D. Mike and distribution(贪心)

Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of pos

WZJRJ28 608

Mike and gcd problem Codeforces Round #410 (Div. 2)

Mike has a sequence A = [a1, a2, …, an] of length n. He considers the sequence B = [b1, b2, …, bn] beautiful if the gcd of all its elements is bigger than 1, i.e. .Mike wants to change his sequence in

FRRE_Y的博客 513

Codeforces Round #410 (Div. 2) D. Mike and distribution (贪心)

原题地址:http://codeforces.com/contest/798/problem/D 题意:有222个序列,长度都是nnn,你需要选出[n2]+1[n2]+1[\frac{n}{2}]+1个下标,使得这些下标对应的元素在a,ba,ba,b任何一个序列中相加的和乘222,都大于该序列所有元素的和. 思路: 首先,对于题目要求的选择元素之和两倍大与所有元素之和,我们可以转化为选择元...

yiqzq的博客 353

Codeforces Round #410 (Div. 2)

啦啦啦,最近比较懒所以之前的坑没有填完,也没怎么写新的博客 5月份就要来了,ytz也要开始勤奋的码代码~\(≧▽≦)/~啦啦啦 Codeforces Round #410 (Div. 2) A.Mike and palindrome 题目已经很良心地加粗了重点了,like this He wants tochange exactly onecharacter from the ...

weixin_33978016的博客 126
上一篇: Gym - 100765I Mars Stomatology 二维dp好题
下一篇: qduoj 帅气的HYC求乘积 dp//蓝桥算法训练 乘积最大
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值