Codeforces Round #652 (Div. 2) B. AccurateLee(思维)

Ubuntu安装ToDesk远程控制软件 前几天有同学问我怎么在 Ubuntu 系统上安装 ToDesk 远程控制软件, 帮他安装完成后就 顺手整理了一下安装过程,所以就顺手有了这篇在 Ubuntu 系统上安装 todesk 的文章。 阅读详情

题目传送
题意:
给你一个01字符串,现在你可以删除其中的一些子序列,要求如下:
当遇到1 0的俩个连续子字符串后,可以删除其中的一个字符,现在要求把他删到尽量最短并且字典序最小,问最后删后的字符串是?

思路:
例:
如果有这样的子结构:111110000那么肯定是只保留到最后一个0,这样会使得最短且字典序最小。

又如1010001010100这个仔细想想会发现,其实也是保留最后一个0使得最短最小。

那么再举几个例子就会发现,我们只要一个子结构的第一个字符为1,最后一个字符为0,那么中间的就都可以删掉。所以我们找到原字符串中的最小位置的1和最大位置的0,那么这俩个位置的所连成的片段,除了最后一个0不删,其他就都删除。

AC代码

#include <bits/stdc++.h>
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 1e5 + 10;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const long long mod = 1e9+9;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t,n;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> n >> s;
        int num0 = 0,num1 = INF;
        for(int i = 0;i < n;i++)
            s[i] == '0' ? num0 = max(num0,i) : num1 = min(num1,i);//寻找最大位置的0,,和最小位置的1
        if(num1 >= num0)//如果最小位置的1还在0的右边,那么直接改不了
        {
            cout << s << endl;
            continue;
        }
        for(int i = 0;i < num1;i++) cout << s[i];
        for(int i = num0;i < n;i++) cout << s[i];//删除中间片段
        cout << endl;
    }
}

别再硬啃理论了!手把手教你用Simulink搭VSG并网模型,模拟线路故障(含三相故障模块详解) 本文提供了一份详细的Simulink VSG并网模型搭建指南,特别聚焦于三相故障模块的配置与仿真。通过逐步指导,帮助电力电子工程师掌握从基础电路搭建到复杂故障模拟的全流程,包括单相接地、两相短路等典型故障的波形分析与参数设置技巧,有效弥合理论与实践的鸿沟。 阅读详情

相关推荐

Veristand自动化测试:Stimulus Profile Editor实战指南

本文是Veristand自动化测试中Stimulus Profile Editor的实战指南。详细介绍了如何利用这一图形化工具,将繁琐的手动测试流程转化为一键自动执行的“剧本”,涵盖工程控制、信号编程、预制动作调用等核心功能,并通过手把手案例演示了构建首个自动化测试脚本的全过程,帮助测试工程师显著提升效率与可靠性。

dd012的博客 492

2021-03-03

题目链接 https://codeforces.com/problemset/problem/1369/B B. AccurateLee time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Lee was cleaning his house for the party when he found a messy string under the c

m0_50690890的博客 301

1.毫米波雷达心率、呼吸原理实现(一)实例

毫米波雷达心率、呼吸检测原理本项目分两到三篇文章写完,第一阶段借鉴TI开源项目以及根据自己的见解适当更改信号处理链通过AWR1843汽车雷达传感器和DCA1000采集卡采集数据完成人体呼吸和心跳检测算法的实现。第二阶段将仿真成功的代码搬移TIAWR1843传感器并通过串口数据实现生命体征的实时处理。本文即为第一阶段实现过程。本文首先概述毫米波雷达呼吸心跳检测的原理,紧接着概述本项目信号处理流程,另外本项目第一阶段通过matlab仿真验证算法的有效性,仿真源码可关注小编并私信可取。1.概述。

Poulen的博客 2万+

B. AccurateLee

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in

无知的我 2331

香橙派OPi 6系列选型指南:RK3588与RK3588S开发板深度对比

开发板选型是嵌入式系统设计的关键环节,尤其在边缘计算和AI推理等场景中,芯片的差异直接影响硬件架构。瑞芯微RK3588及其精简版RK3588S是当前高端开发板的核心方案,两者在PCIe通道、显示输出和SATA支持上存在显著区别。理解这些原理,有助于工程师根据项目需求快速匹配产品。香橙派OPi 6系列基于这两款芯片,衍生出OPi 6、OPi 6 Pro与OPi 6 Max三种形态:紧凑型适合嵌入式门禁与AI盒子,Pro版凭借双屏异显和PCIe 3.0满足收银机与视频分析,Max的双2.5G网口和大内存则面向轻

weixin_29185167的博客 224

新能源知识库(62)组串式、集中式和高压直挂式

因需多台PCS及独立监控设备,单位功率成本比集中式高15%–20%。高压直挂式因省去变压器,大容量项目成本更低(>5MW时优势显著)。组串式储能、集中式储能和高压直挂式储能是当前主流的三类技术路线,其核心差异源于系统架构和控制逻辑的设计差异。组串式交流侧需变压器升压至10kV/35kV,高压直挂式可直接输出6kV/35kV电压,减少转换损耗。多台小功率PCS并联(每簇独立管理)单台大功率PCS(多簇直流侧并联)环流导致容量衰减(损失5%–8%)无变压器损耗(效率>99%)高压直挂电站(≥10MW)

竹君子之家 1515

Codeforces Round #652 (Div. 2)

A - FashionabLee 题意 问你一个正n边形,您能否旋转它,让他的某一条边平行于x轴另一条边平行于y轴。 思路 要让他有平行于x轴的边的同时,也有平行于y轴的边。 那么我们只需要让他n边形的360/n是90度的倍数关系即可。画图验证更快。 #include<bits/stdc++.h> #define INF 0x3f3f3f3f #define DOF 0x7f7f7f7f #define endl '\n' #define mem(a,b) memset(a,b,sizeof(a

ACMer_WarYan 302

万字长文,小白新手怎么开始做YOLO实验,从零开始教!整体思路在这里,科研指南针!

万字长文,小白新手怎么开始做YOLO实验,从零开始教!整体思路在这里,科研指南针!

Coding... 1万+

#652 (Div. 2)B. AccurateLee(找规律)

题目描述 Lee was cleaning his house for the party when he found a messy string under the carpets. Now he’d like to make it clean accurately and in a stylish way… The string s he found is a binary string of length n (i. e. string consists only of 0-s and 1-s).

li_wen_zhuo的博客 585

量化交易 米筐 案例:市值因子选股策略

案例:市值因子的选股策略 1.结果 获得超额收益 年化 49% 2. 从股票中选择市值小的股票 选定财务数据筛选 进行每日调仓(多因子选股调仓 周期频率会小一些) 3. 代码 估值有关指标 # 在沪深300股票中,选出市值比较小的10只股票 # 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。 def init(context): # 沪深300组合 stocks = index_components('000300.XSHG') # 沪深3

廷益_飞鸟的博客 2311

Python爬虫实战:高效爬取CNKI知网文献数据的技术解析

本文将详细介绍如何使用Python最新技术构建一个高效的CNKI知网文献爬虫系统。我们将从爬虫基础知识讲起,逐步深入到高级反反爬技术、分布式爬取、智能解析等前沿内容。文章包含完整的代码实现,涵盖请求模拟、数据解析、持久化存储等关键环节,并特别针对CNKI的反爬机制提供解决方案。通过本文,读者将掌握构建专业级学术文献爬虫的全套技术栈。关键词:Python爬虫、CNKI爬取、反反爬技术、文献数据挖掘、Scrapy框架本文详细介绍了如何使用Python最新技术构建CNKI知网文献爬虫。

2201_76125261的博客 2075

Codeforces Round #652 (Div. 2)-B. AccurateLee(字符串,思维)

题目链接 题意: 给你一个01串,你可以删除所有的10子串其中的一个字符,求怎样能够使得字符串长度最短。 思路: 因为你可以删除所有的10中的一个字符,所以我们只需要寻找到第一个1和最后一个0的位置,然后删除掉中间的所有数字和开头末尾10中的一个即可。 代码: #include<bits/stdc++.h> using namespace std; #define int long long #define IOS ios::sync_with_stdio(false);cin.tie(0);c

ACkingdom的博客 951

泰凌微8258入门教程 基础篇①——Bluetooth® SIG Mesh 快速上手

Bluetooth® SIG Mesh Quick Start

6729

Codeforces Round #652 (Div. 2) B. AccurateLee 题解(思维)

题目链接 题目大意 给出一个01组成的字符串,如果字符串中有“10”结构,那么就可以删除这个1和0中的一个数,求怎么删才能让该字符串最小。 题目思路 emmm。。。好久没写题了,太蠢了,没想到。 我们可以删掉该字符串从第一个‘1’出现的位置开始到最后一个‘0’出现的位置为止(不包括最后一个0)中间的所有数。 自己模拟一下就懂了 代码 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; typedef long lo

hunxuewangzi的博客 4722

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces B. AccurateLee (思维 / 判断 / 二进制串) (Round #652 Div.2)

传送门 题意: 有一个01字符串需要清理,对于每个"10"子串,你都可以选择其中一个字符清除。标准规则认为越短的串越干净,同样长的串字典序越小越干净。先让你安装标准规则清理字符串,并输出最干净的结果。 思路: 找到左边第一个 ‘1’ 的下标pos1,已经右边第一个 ‘0’ 的下标pos0。 若其中没有’0’或没有’1,'或者所有0在1的左边就直接输出原字符串。 在整个字符串中部(pos1 到 pos0之间):所有的 ‘1’ 都可被pos0位置的 ‘0’ 清除掉,而所有的 ‘0’ 可以不pos1位置的 ‘

Satur9的博客 294

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Codeforces Round #652 (Div. 2) A~E

链接:题目 赛后总结Codeforces Round #652 (Div. 2)A.FashionabLeeB.AccurateLeeC. RationalLeeD. TediousLeeE. DeadLee小总结 Codeforces Round #652 (Div. 2) A.FashionabLee 题意:能不能构造多边形和x轴,y轴同时平行 思路:边数得是偶数的同时,同时满足(n-2)/2为奇数 int main(){ int _; for(scanf("%d" , &_);

weixin_43818893的博客 464

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Codeforces Round #652 (Div. 2)部分题解

太久没打比赛果然还是变菜了 这场div2 前三题都不难 传送门 A.FashionabLee 题意:正n边形,如果存在两条边,一条边平行于x轴,一条边平行于y轴,则输出yes,否则输出no 思路:我当时的想法是,我们先选择任意一条边与y轴平行,然后由于是正n边形,每个外角为θ=360n\theta=\frac{360}{n}θ=n360​ 。每条边就是往这个方向偏移了θ\thetaθ,那么要偏移到与x轴平行,则需要正好偏移90360n=n4\frac{90}{\frac{360}{n}}=\frac{n}

qq_43290092的博客 348

Codeforces Round #652(div2)

A.FashionabLee 解题思路:以正四边形为基础,首先正方形时x轴平行边和y轴平行边之间直接连接,边数大于4时,把x轴平行边和y轴平行边拿开,观察将它们再次连接需要几条边就补几条边,此时得到的多边形必定满足条件,容易推知,构成8边形时恰好补四条边,补八条边构成12边形,每次补4条边,容易推知4的倍数即可满足 ac code: #include<iostream> using namespace std; int main() { int n,t; cin>>t; w

fusu123456789的博客 205

Codeforces Round #652 (Div. 2) #B. AccurateLee

B. AccurateLee time limit per test2 seconds memory limit per test256 megabytes input:standard input output:standard output Lee was cleaning his house for the party when he found a messy string under the carpets. Now he’d like to make it clean accurately

EiVise的博客 320

Codeforces Round #652 (Div. 2) B. AccurateLee

B. AccurateLee 题目链接-B. AccurateLee 题目大意 给出一个000和111组成的字符串,如果字符串中有101010结构,那么就可以删除这个111和000中的一个数,求该字符串删除后最短且字典序最小的字符串 解题思路 先求出最右边000的位置xxx和最左边111的位置yyy,如果y>xy>xy>x则说明原串是0…10…10…1格式的,此时的字典序最小,所以无需删除字符 如果y<=xy<=xy<=x,为了让得到的答案最小,101010要删掉1

Fiveneves的博客 269

Codeforces Round #652 (Div. 2) A-D题

比赛链接:https://codeforces.com/contest/1369 A.FashionabLee 判断边数是否为4的倍数 #include <iostream> using namespace std; int main() { int T; cin>>T; while(T--){ int n; cin>>n; if(n%4==0)cout<<"YES"<&lt

qq_41648012的博客 315

Codeforces Round #652 (Div. 2) C. RationalLee

C. RationalLee time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought n integers, now it’s time to dis

张洪基 338

Codeforces Round #652 (Div. 2) E - DeadLee (贪心)

#include <iostream> #include <cstring> #include <cstdio> #include <queue> #include <algorithm> #include <cmath> #include <vector> #include <map> using namespace std; #define inf 0x7fffffff #define ll long lo.

逝者如斯夫,不舍昼夜 4840

Codeforces Round #652 (Div. 2) C,D

首先w[i]==1的情况肯定直接分配最大值。 对于剩余情况: 我如果我们预先把1-n的a[i]值都加上记为sm。 对于w[i]==x的情况:相当于: 选取一段区间[l,r] r-l+1=x, sm的值减去[l+1,r-1]区间内的a[i]。 我们的目的是让所有w[i]对应的区间,减去的值和最小。 显然,让w[i]最大的区间放在最前面,然后依次放下去,减的数和最小。否则只要变东任意一个区间,整体减去的区间会变大。 #include <bits/stdc++.h> usi...

bjfu170203101的博客 355

[codeforces 1369C] RationalLee 自大到小分配+自少向多分配+不定长数组的使用

Codeforces Round #651 (Div. 2) 参与排名人数14559 [codeforces 1369C] RationalLee 自大到小分配+自少向多分配+不定长数组的使用 总目录详见https://blog.csdn.net/mrcrack/article/details/103564004 在线测评地址http://codeforces.com/contest/1369/problem/C Problem Lang Verdict Time ...

mrcrack的博客 852

Codeforces Round #652 (Div. 2)-C. RationalLee

题目链接 题意: 给你n个数,将他分成k组,求每一组的最大值和最小值相加得到的值的总和是多少。 思路: 首先想要总和最大,那么我们要尽可能使最大值最大,最小值尽可能大,我们先将两个数组排序,如果有k数组为1的情况,那么最大最小值相同,所以我们把最大的值放入1的堆中。当需要分的堆大于1时,首先我们要确保最大值为最大的,其次,最小值尽可能大,如果我们放入所有数字的最小值,那么其余的值不论有多小都不会对答案有影响,所以我们要利用这一点,放入一个最大值和最小值之后,把剩下的数从最小开始放入该数组中,使得下一个数组的

ACkingdom的博客 336
上一篇: 西南科技大学第十六届ACM程序设计竞赛暨绵阳市邀请赛 (补题计划)(思维,数学等等)
下一篇: Codeforces Round #652 (Div. 2) C. RationalLee(思维,sort)
鸣蜩二九~
博客等级 码龄7年 167粉丝 391原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值