cf#579 E

自旋玻璃(spin glass)、自旋冰(spin ice)和量子自旋液体(quantum spin liquid)(之二) 具有相同电荷的电子相互排斥。结果,为了在极其拥挤的环境中相互超越,他们不得不改变自己的行为。剑桥大学和英国伯明翰大学于 2009 年 7 月发表的研究表明,电子可以通过量子隧穿从金属表面跳到相近位置的量子线上,这样做后,将分离成两个准粒子,命名为的自旋子和全子。Van den Brink、Khomskii 和 Sawatzky 在 1997-1998 年对轨道子进行了理论上的预测。在 2011 年 9 月发给出版商的论文中报告了它作为一个单独的准粒子的实验观察结果。 阅读详情

http://codeforces.com/contest/1203/problem/E
E. Boxers
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
There are n boxers, the weight of the i-th boxer is ai. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number.

It is necessary to choose the largest boxing team in terms of the number of people, that all the boxers’ weights in the team are different (i.e. unique).

Write a program that for given current values ​ai will find the maximum possible number of boxers in a team.

It is possible that after some change the weight of some boxer is 150001 (but no more).

Input
The first line contains an integer n (1≤n≤150000) — the number of boxers. The next line contains n integers a1,a2,…,an, where ai (1≤ai≤150000) is the weight of the i-th boxer.

Output
Print a single integer — the maximum possible number of people in a team.

Examples
inputCopy
4
3 2 4 1
outputCopy
4
inputCopy
6
1 1 1 4 4 4
outputCopy
5
Note
In the first example, boxers should not change their weights — you can just make a team out of all of them.

In the second example, one boxer with a weight of 1 can be increased by one (get the weight of 2), one boxer with a weight of 4 can be reduced by one, and the other can be increased by one (resulting the boxers with a weight of 3 and 5, respectively). Thus, you can get a team consisting of boxers with weights of 5,4,3,2,1.
给一个长度为n的数组,每个数组可以加一减一或者不变,要使不同数字最多,从前往后遍历,先看x-1有没有数字,有的话-1,没有的话再看x,同理最后看x+1.

#include<stdio.h>
#include<algorithm>
using namespace std;
int a[150005],vis[150005],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",a+i);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[a[i]-1]==0&&a[i]!=1)
		{
			ans++;
			vis[a[i]-1]=1;
			continue;
		}
		else if(vis[a[i]]==0)
		{
			ans++;
			vis[a[i]]=1;
			continue;
		}
		else if(vis[a[i]+1]==0)
		{
			ans++;
			vis[a[i]+1]=1;
			continue;
		}
	}
	printf("%d\n",ans);
}
从入门到精通|Yalmip+Cplex在电力系统中的应用(Matlab代码实现) ​ 火电成本包括运行成本、碳捕集成本,其中火电运行成本由运行维护成 本和发电煤耗成本构成,发电煤耗与其出力关系: ,F 为机组煤耗量(kg/h),P 为机组出力/MW;运行维护成本按照 0.5 倍煤耗成本考虑,碳捕集成本取决于碳排放量及碳捕集单价,火电机组相关参数如附表 1 所示,电煤价格为 700 元/t ​ 阅读详情

相关推荐

360可视门铃双摄版数据恢复实战:BIN文件解析与视频重组

本文详细解析了360可视门铃双摄版BIN文件的数据恢复过程,包括文件结构分析、双摄像头数据存储机制及视频重组技术。通过Python开发环境和FFmpeg工具链,成功实现了H.265视频流的解析与重组,为智能家居设备数据恢复提供了实用解决方案。

weixin_29196891的博客 912

CF网络流练习

1. 103E 大意: 给定$n$个集合, 满足对于任意的$k$, 任意$k$个集合的并集都不少于$k$. 要求选出$k$个集合$(k> 0)$, 使得并恰好等于$k$, 输出最少花费. Hall定理: 二分图的$X$部到$Y$部有完美匹配等价于$X$中任意$k$个点与$Y$中至少$k$个点相邻. 所有集合为$X$部, 每个数为$Y$部, 集合向所含数连边, 那么一定存在完美...

weixin_30828379的博客 347

【计算机三级-数据库技术】操作题大题(第1套)

从触发器的语法中可知,【1】处应该填写的是执行触发器的表,【2】处应该填写指定在表或视图上执行哪些数据修改语句时将激活触发器的关键字。使用FOR或AFTER选顶定义的触发器为后触发器,即只有在引发触发器执行的语句中的操作都已成功执行,并且所有的约束检查也成功完成后,才执行触发器。转换成新的独立的模式,模式的属性由联系本身的属性及两个实体的键构成,主键由两端实体的键组合而成。实体的转换:在从ER图转换为关系模式时,一个实体转换成一个关系模式,实体的属性就是关系模式的属性,实体的键就是关系的主键。

放纵小开爱的博客 1102

codefrces 1203 E. Boxers(贪心)

E. Boxers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are

qq_43731011的博客 404

SDN:使用Postman控制ODL查看和下发流表

所谓,其实可被视作是SDN对网络设备的数据转发功能的一种抽象。在传统网络设备中,交换机和路由器的数据转发需要依赖设备中保存的二层MAC地址转发表或者三层的IP地址路由表,SDN交换机中使用的流表也是如此,不过在它的表项中整合了网络中各个层次的网络配置信息,从而在进行数据转发时可以使用更丰富的规则。其流表中的每个表项结果如下图所示:OpenFlow1.3流表的每个表项由6部分组成:1、匹配域:匹配域即OpenFlow1.0流表中的包头域,用于对交换机接收到的数据包的包头内容进行匹配。Ehter Des。

lyhaoyuhangyuan的博客 2535

Spark on Yarn 高可用模式部署流程

本文介绍了如何配置Spark和Yarn的高可用(HA)环境,以确保在大规模数据处理中避免单点故障。

xhaoDream的博客 1446

【网络流】CF311E Biologist

题意 有一个长度为n的01串,将第i个位置变为另外一个数字的代价是vi​ 。有m个要求 每个要求的形式是 首先确定若干位置都要是0 或者1 然后给定这K 个位置,如果些位置上都满足要求 那么就可以得Wk​ 元 某些要求如果失败了还要倒着给g 元 问最终能够得到的最大利润 分析 先考虑每个位置都改成1,再按照最大权闭合的思想建图 初始为0的点:S->i val 初始为1的点:i->T val 0的要求 S->j w(+g) j->u inf 1的要求 j->T -w(-g) u-

andyc_03的博客 352

UDS 诊断 - CommunicationControl(通信控制)(0x28)服务 诊断

字节参数名称字节值#1CommunicationControl(通信控制)请求SID0x28#2#3communicationType(通信类型)#4nodeIdentificationNumer(节点标识符)(高位字节)controlType 为 0x04 或 0x05 时,使用该参数#5nodeIdentificationNumer(节点标识符)(低位字节)controlType 为 0x04 或 0x05 时,使用该参数。

耳朵东金子千的博客 1822

cf708D Incorrect Flow (网络流)

题意 给定一张不一定合法的有源汇网络(包括每条边的容量与流量),你可以修改边的容量与流量,修改的代价是与原值的距离。问你最小修改代价,使得网络合法。 合法的定义是:每条边流量<=容量,除了源汇之外的点流量平衡 n,m≤100n,m\leq 100n,m≤100 分析 网络流题当然要用网络流解决。 对于c≥fc\geq fc≥f的边,容易发现若最终f′>cf'>cf′>c,...

一位蒟蒻的小博客 260

智能车小白也能懂:手把手教你用LM358和工字电感搭建电磁循迹模块(附PCB设计避坑)

本文详细介绍了如何利用LM358运放和工字电感搭建智能车电磁循迹模块,从电感选型、电路设计到PCB布局和焊接调试,提供全流程实战指南。特别针对新手常见问题,如信号干扰、电路饱和等,给出具体解决方案和参数配置,帮助智能车比赛爱好者快速掌握电磁循迹技术。

weixin_30307921的博客 403

对CryptoDriver里密钥格式定义的探索(1)

一入网络安全才发现深似海,传统汽车MCU码农转型之路异常艰难。在CP AUTOSAR中的CryptoDriver SWS对密钥格式的需求来源于RFC,其中要求了RSA、ECC、SHE等key material的格式。再往下看,我就有些迷糊了,例如关于RSA Private Key的OCTEE STRING格式根据IETF RFC8017,Public Key又得根据RFC5280,完全不得其解。所以今天先从生成密钥对,并对其进行解析开始,一步一步拆解。

认真搞搞汽车MCU 528

2018.1.30 训练日记--网络流+cf

今天继续看的网络流,看的饶齐的博客,见识了网络流各种奇怪的用法。。。 晚上打了一场cf。。C挂了终测,,估计又要掉分。。。。D题一直WA,,也不知道错在哪里,。心好塞。。。

AAAAAAAC的博客 283

ICC2: pin shape不在track上引起的drc如何解决?

我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 435

cf#579A

http://codeforces.com/contest/1203/problem/A A. Circle of Students time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n students standi...

evilwind2000的博客 277

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

cf#579 D

http://codeforces.com/contest/1203/problem/D2 D2. Remove the Substring (hard version) time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The only...

evilwind2000的博客 196

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

CF#579div.3

只写了4题...(BCDE) A和F太长就懒得看了... B题题意:给你4*n个小木棍,问你能不能拼出n个面积相同的矩形 做法:排序后,最大的和最小的组成一个矩形 C题题意:求满足所有的$[ai%x==0]$的x的个数 做法:求gcd然后分解gcd D题题意:给你两个字符串s,t满足t是s的子序列,删掉一个子串使得t仍然是s的子序列,问你子串长度最大是多少 ...

ailaiqu0715的博客 174

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【CF#579】A. Raising Bacteria

题目链接 若是2的倍数,则只用放一个细菌。即1>>i, 若不是2的倍数,则看输入数字中(转为2进制有多少个1),有多少个1就有多少个细菌。 /* *author:percation *date:2022.1.15 */ #include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; typedef long long ll; ll n,t; int a[N]; map<int,int> m.

qq_45866781的博客 209

CF 1214 D Treasure Island 网络流

有一个nm的格子, 一个人起点11, 目的点是nm可以往右/往下走, #为不能走的点, 问做少把几个.改成#(不能改起点和终点)能让这个人不能走到. 当然最多改2个鸭 最小割就是最大流啊 网络流冲冲冲 把图里的每个格子拆成两个点, 其间的流量就是去掉这个点的代价(1), 当然第一个点和最后一个点代价是inf. 然后每个点的2号向其下/右的点的1号连边, 流量是inf. 然后从起点到终点跑网络流就行...

swqeaaa的博客 583

CF786E-ALT【网络流,倍增】

正题 题目链接:https://www.luogu.com.cn/problem/CF786E 题目大意 nnn个点的一棵树,mmm个人每个人走一个路径。 给一些人狗或者一些边狗每个人要求要么它自己有狗要么它走的路径上都有狗。 解题思路 考虑最小割,其实就是要么割一个人要么割一整条路径,然后倍增优化连边即可。 codecodecode #include<cstdio> #include<cstring> #include<algorithm> #include&lt

QuantAsk 419

cf724E. Goods transportation 网络流+dp

Description There are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road. The i-th city had produced pi units of goods. No more than si units of ...

olahiuj的博客 594

cf1203E E. Boxers

E. Boxers time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n boxers, the weight of the i-th boxer is ai. Each of them can change the ...

dream_it_的博客 499

CF 1070I Privatization of Roads in Berland 网络流

http://codeforces.com/contest/1070/problem/I 题意: 给你一个无向图,每条边连接两个城市,现在要给每条边分配一个颜色,每个颜色不能被用超过两次, 每个城市最多被k种颜色连,问是否存在,输出方案。 题解: 设一个城市和deg[i]条边相连,如果deg[i] &gt; k, 那么起码要把2 * (deg[i] - k)条边两两合并成同一颜色。 对于...

c6376315qqso的专栏 669

018 Boxers (CF1203E)

题目链接:CF1203E 标签:贪心、排序 大意:给你n个数,每个数可一个+1,-1,或不变(变化后必须为正整数),问最多可能存在多少个不同的数 思路:由大到小排序,1特判从最左边的数开始,尽量往小了变,开个数组来标记这个值是否出现过,代码如下,细节请看注释: #include<bits/stdc++.h> using namespace std; const int maxn=150...

饮冰室 251

CF 589F 网络流(or贪心?)

题目链接:http://codeforces.com/problemset/problem/589/F 题意:有n盆菜,每个菜的上菜时间是ai-bi,要求每盆菜的品尝时间都相同,求最大的品尝时间。 思路:一开始也想到了网络流,但是没有想到压缩区域。。。(我只想到一个点一个点地建图,这个的图点可能有10^4个啊。。肯定不能用网络流),后来请教别人可以一个区间建图,流量就是区间长度

qwe2434127的专栏 785

【网络流-最大权闭合子图】CF1082G Petya and Graph

【题目】 原题地址 给定一幅图,求子图的最大权值,权值定义为边权和-点权和。 n,m≤103n,m\leq 10^3n,m≤103,边权≤109\leq 10^9≤109 【解题思路】 十分经典的最小割建图。 对于每个点(id,w)(id,w)(id,w),连(S,id,w)(S,id,w)(S,id,w),对于一条边(id,u,v,w)(id,u,v,w)(id,u,v,w),连(u,id,IN...

MEET YOU FIRST TIME 573

cf-546E 网络流,状态转移平衡

E. Soldier and Traveling time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In the country there are n cities a

写东西的地方 836
上一篇: cf#579 C
下一篇: cf#579 F1
evilwind2000
博客等级 码龄7年 24粉丝 84原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值