BZOJ 1150: [CTSC2007]数据备份Backup 堆,贪心

精通DC-DC变换器:Boost升压电路全解析 Boost升压变换器是一种将低直流电压转换为高直流电压的常用电路。其核心工作原理是通过电感储能:开关导通时电感充电,关断时电感与电源串联向负载供电。关键公式表明输出电压Vo=Vi/(1-D),占空比D越大,升压比越高。变换器工作时会产生电感电流纹波和输出电压纹波,需合理选择电感和电容参数。开关管和二极管需承受完整的输出电压,对元器件选型要求较高。理解这些原理是设计高效升压电源的基础。 阅读详情

题意: 有n栋楼排成一排,要求在k对楼之间连接电缆,每栋楼只能被连接一次,求最小的∑|dis[x]−dis[y]|.x,y分别为电缆的两个端点。n<=100000
解题方法: 显然k对电缆连接的必然都是相邻的两栋楼,那么问题可以转换成有n-1个数,a[i]=dis[i+1]-dis[i],从中取出k个数满足其互不相邻且和最小。那么就可以用贪心来做。每次找一个最小的,假设是x,那么x+1和x-1要么不选,要么都选,那么可以把这三个数合并成一个数,权值为a[x+1]+a[x-1]-a[x],然后把原来的三个数删掉即可。可以用优先队列和双向链表来维护。为了方便的使用priority_queue,直接把a[n]设为-inf就可以了。细节见代码

//bzoj 1150
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const int maxn = 100010;
typedef long long LL;
inline int read()
{
    char ch=getchar();
    int f=1,x=0;
    while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}
inline LL llread(){
    char ch=getchar();
    LL f=1,x=0;
    while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}
struct node{
    int pos;
    LL v;
    node(){}
    node(int pos, LL v) : pos(pos), v(v) {}
    bool operator < (const node &rhs) const{
        return v < rhs.v;
    }
};
priority_queue <node> que;
int n, m, L[maxn], R[maxn], vis[maxn];
LL a[maxn], dis[maxn];

int main(){
    n = read(); m = read();
    while(!que.empty()) que.pop();
    for(int i = 1; i <= n; i++) dis[i] = llread();
    for(int i = 1; i <= n; i++){
        if(i < n) a[i] = dis[i] - dis[i + 1];
        else a[i] = -inf;
        node u; u.v = a[i]; u.pos = i;
        que.push(u);
        R[i] = i + 1; L[i] = i - 1;
    }
    R[n] = 1; L[1] = n;
    LL ans = 0;
    for(int i = 1; i <= m; i++){
        node now = que.top(); que.pop();
        while(vis[now.pos] && !que.empty()){now = que.top(); que.pop();}
        ans -= now.v;
        int x = now.pos;
        node v;
        v.pos = x; v.v = a[x] = 1LL * (a[R[x]] + a[L[x]] - a[x]);
        que.push(v);
        R[L[L[x]]] = x;
        L[R[R[x]]] = x;
        vis[L[x]] = 1;
        vis[R[x]] = 1;
        R[x] = R[R[x]];
        L[x] = L[L[x]];
    }
    printf("%lld\n", ans);
    return 0;
}
【人工智能时代】- 一键部署本地AI大模型 Ollama是一个开源项目,致力于简化大型语言模型(LLM)的本地部署过程。它允许用户在自己的硬件上运行和测试最新的语言模型,无需依赖云服务。Ollama提供了一个类似于OpenAI的API接口,使得开发者可以轻松地在自己的应用程序中集成大型语言模型。此外,Ollama WebUI为用户提供了一个友好的界面,用于管理和与模型进行交互。 阅读详情

相关推荐

IGV新手必看:5分钟搞定ChIP-seq/DAP-seq/ATAC-seq数据可视化(附常见报错解决方案)

本文为IGV新手提供了一份快速上手的实战指南,详细讲解了如何高效完成ChIP-seq、DAP-seq、ATAC-seq等数据的可视化。内容涵盖软件安装、基因组导入、文件格式转换与优化,并重点剖析了“导入后一片空白”等常见报错的根本原因与解决方案,帮助用户在5分钟内避开雷区,生成可用于发表的IGV专业图谱。

weixin_29198045的博客 537

bzoj1150 数据备份(贪心)(链表)(堆)

题意 给出n个点的位置,选择不重复的2*k个点进行匹配,求匹配后两点距离最小和。   题解 堆+链表+贪心 先进行一步转换,相邻间求个距离。现在问题就转化成了在n个数中选取互不相邻的k个数,使得总和最小。 当k=1时,选取最小值。 当k=2时,要么选最小值(位置i)和不相邻(即除i,i-1,i+1外)的次小值,要么选i-1和i+1。 基于这两点我们就可以开始设置后悔机制了。当选择了a[i...

A_Bright_CH的博客 450

手把手教你如何修改YOLO11的模型结构(以CBAM和可变性卷积为例)

YOLO11修改模型结构

2401_86807530的博客 1万+

BZOJ 1150: [CTSC2007]数据备份Backup

堆

sdfzrlt的博客 875

Allegro网表导入报错VOIDs not allowed in parent SHAPE的解决方案

在PCB设计流程中,网表导入是确保电气连接正确传递的关键步骤。其原理是将原理图的逻辑连接关系映射到物理版图的图形数据库中。这一过程的技术价值在于保证设计数据的一致性,避免后续生产中出现电气错误。然而,在Cadence Allegro等EDA工具的实际应用中,数据库内部状态的不一致可能引发操作失败,例如常见的“VOIDs are not allowed in the parent SHAPE”报错。这类问题通常源于多人协作、跨版本操作或频繁编辑后积累的数据结构冗余。针对此场景,核心的解决方法是执行Databa

weixin_30954817的博客 319

Mac安装Claude Code的3种方式及5类报错解决方案

介绍在Mac上安装Claude Code的3种实测可行方式(官方dmg、Homebrew+ARM原生构建、Docker容器化),并针对Gatekeeper签名验证失败、Rosetta 2内存对齐崩溃、Python ABI兼容性冲突等5类高频报错提供根因分析与可复现解决方案,覆盖M1–M3及Intel

weixin_28728443的博客 361

【BZOJ 1150】 [CTSC2007]数据备份Backup

非常非常巧妙的贪心+堆~

Regina8023 2013

基于RK3568的YOLOv11模型端侧推理优化与部署实战指南

在AI边缘计算领域,瑞芯微RK3568芯片凭借其强大的NPU算力和丰富的接口资源,成为了众多开发者的首选平台。然而,瑞芯微官方文档虽然提供了YOLO11预训练模型的部署方案,但对于需要自定义数据集训练的开发者来说,从模型训练到板端部署的完整流程却缺乏详细指导。本文将带你走完从环境搭建、数据准备、模型训练到最终板端部署的完整技术路线,并分享实际开发中遇到的各种坑点和解决方案。让我们一起探索如何在RK3568平台上实现30FPS稳定推理的YOLO11目标检测应用!

m0_64661770的博客 115

bzoj1150: [CTSC2007]数据备份Backup(堆+贪心)

题目传送门 。 解法: 跟上一题差不多一个思想。 bzoj2151 只不过这题多了一个比较恶心的边界而已。 那么相对于边界值。就拿他前面没有点来举例。 假设现在前面没有点了。那么肯定选他之后不用反悔啊。 因为你后面那个肯定比你小啊要不然干嘛选你呢。 所以说选完之后把自己和后面的点删除就行了。 维护一下即可。 跟2151唯一的不同也就这个点了。 如果后面没有点也是一样的道理。...

Hanks_o的博客 458

YOLOv8-pose姿态估计模型从训练到RK3588部署:让边缘端骨骼识别速度突破60FPS

本教程从“模型训练-转换-边缘部署”全链路拆解了YOLOv8-pose姿态估计方案在RK3588上的落地过程,每一步都经过实战验证。无论是智能健身的动作实时纠正,还是工业设备的关键部件姿态检测,这套流程都能让你以最低成本实现高精度、高实时性的姿态估计应用。如果你在实践中遇到模型转换报错、部署性能不达标等问题,可聚焦某一环节深入优化——毕竟,让AI在边缘端“精准捕捉每一个关键点”,才是技术驱动场景创新的核心。

know_F0727的博客 189

ValueError:Using a `device_map`, `tp_plan`, `torch.device` context manager or setting `torch.set解决方案

本文主要介绍了ValueError:Using a `device_map`, `tp_plan`, `torch.device` context manager or setting 'torch.set_default_device(device)` requires `accelerate`解决方案,希望能对使用transformers的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 3万+

BZOJ 1150 [CTSC2007]数据备份Backup(贪心+优先队列)

【题目链接】http://www.lydsy.com/JudgeOnline/problem.php?id=1150 【题目大意】   给出n个数,请你挑出k对(每个数不可重复选取),使得他们差的绝对值之和最小(k小于等于n/2) 【题解】   因为数列给出有序,省去排序步骤,我们发现最优答案一定是选择k对相邻的数,   因此我们将相邻的数两两之间求差,得到差分数...

weixin_30362083的博客 128

2024年03月CCF-GESP编程能力等级认证Python编程五级真题解析

下面流程图在yr输入2024时,可以判定yr代表闰年,并输出 2月是29天 ,则图中菱形框中应该填入( )。 A. (yr % 400 == 0) or (yr % 4 == 0) B. ( yr % 400 == 0) or (yr % 4 == 0 and yr %100 != 0) C. ( yr % 400 == 0) and ( yr % 4 == 0) D. (yr % 400 == 0) and (yr % 4 == 0 and yr % 100 != 0)

人生就是一个不断学习的过程 743

bzoj 1150: [CTSC2007]数据备份Backup 贪心&堆

首先连接的显然是相邻的一对楼,那么我们对于这些办公楼求出相邻的之间的距离构成的长为N-1序列,相当于在里面取出K个不相邻的数使它们和最小。        显然每次贪心地取,然后考虑取走一个数后和它相邻的部分,如果要取且增加一个数,那么权值为新增的数的和-要去掉的权值的和。然后扔进优先队列即可。 AC代码如下: #include #include #include #include #incl

lych的博客 1174

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

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

[贪心+堆] BZOJ1150: [CTSC2007]数据备份Backup

题意直线上有n个点,选K对点之间连线,一个点只能连出去一条线,求连线的总长度的最小值。 n<=1000000,k<=n/2题解贪心真可怕…… 显然要连肯定是连相邻的。我们把n-1个相邻差值拿出来,问题转换为n-1个数中取K个不相邻的数的和的最小值。 n比较大,考虑贪心: 如果我取了最小的数会怎么样呢?显然是不对的: 例如:2 1 2 100, 取2个 如果第一次取了 11,之后只能取 1

Lynstery's blog 852

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

[BZOJ]1150 1150: [CTSC2007]数据备份Backup 贪心 + 堆

1150: [CTSC2007]数据备份Backup Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 2556  Solved: 1028 [Submit][Status][Discuss] Description   你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份。然而数据备份的工作是枯燥乏味 的

Le Petit Prince 378

深度学习工具包 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")

bzoj1150: [CTSC2007]数据备份Backup--贪心+优先队列维护堆

题目大意:将k对点两两相连,求最小长度 易证得,最优方案中,相连的办公楼一定是取相邻的比取不相邻的要更优 然后就可以用贪心来做这道题了。。 之前向CZL大神学习了用堆来贪心的做法orz 大概思路就是将初始所有的线段放进堆里 每次取最短的线段进行连接,且ans+=a[i] 取完后删除当前线段,与相邻的两条线段,同时再插入新边,权值为a[pre]+a[next]-a[now] 其作...

weixin_30387423的博客 113

BZOJ1150 [CTSC2007] 数据备份Backup 贪心_堆_神题

BZOJ1150 [CTSC2007] 数据备份Backup 贪心_堆_神题 非常神的一道题. Code: #include<bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) #define maxn 1000000 #define inf 10000...

EM LGH 145

BZOJ_1150_[CTSC2007]数据备份Backup_堆+贪心

BZOJ_1150_[CTSC2007]数据备份Backup_堆+贪心 Description   你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份。然而数据备份的工作是枯燥乏味 的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家中尽享计算机游戏的乐趣。已知办公 楼都位于同一条街上。你决定给这些办公楼配对(两个一组)。每一对办公楼...

107

BZOJ 1150: [CTSC2007]数据备份Backup【贪心】

1150: [CTSC2007]数据备份Backup 【题目描述】 传送门 【题解】 都说贪心是最难的,果然很难。 我们肯定选择相邻的连边,这题就变成了从n-1条边中选出k条不相邻的边的最小代价。 这题我们有个贪心的想法,挑小的好,但是肯定有反例,那么我们取出一条边时,将这条边两边的边放进去,新的代价是放入的两条边-取出的边,下...

aiweiluan5095的博客 120

bzoj1150: [CTSC2007]数据备份Backup 贪心

bzoj1150: [CTSC2007]数据备份Backup Description   你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份。然而数据备份的工作是枯燥乏味 的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家中尽享计算机游戏的乐趣。已知办公 楼都位于同一条街上。你决定给这些办公楼配对(两个一组)。每一对办公楼可以通过在这两个建筑...

maxtir的博客 284

【链表】bzoj 1150: [CTSC2007]数据备份Backup

1150: [CTSC2007]数据备份Backup Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1136  Solved: 458[Submit][Status][Discuss] Description   Input 输入的第一行包含整数n和k,其中n(2 ≤ n ≤100 000)表示办公楼的数目,k(1

puck_just_me的blog 584

[CTSC2007][APIO2007]数据备份Backup

题目:BZOJ1150、codevs1615、洛谷P3620 题目大意:有n个点,k条链,每个点离原点有一定的距离。要你用k条链连接2k个点,使得k条链的长度最短。 解题思路:毕竟是CTSC级别的题目,很难找出正确算法。在网上翻阅了很多资料后,终于理解了此题的正确算法。orz 正确算法为:贪心+链表+堆。 首先每次肯定是链相邻的2个点,所以我们先把相邻2个点的差值求出来,得到有n...

151

bzoj1150-[CTSC2007]数据备份Backup

Description 你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份。然而数据备份的工作是枯燥乏味的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家中尽享计算机游戏的乐趣。已知办公楼都位于同一条街上。你决定给这些办公楼配对(两个一组)。每一对办公楼可以通过在这两个建筑物之间铺设网络电缆使得它们可以互相备份。然而,网络电缆的费用很高。当地电信公司仅能...

weixin_34392906的博客 123

【BZOJ 1150】[CTSC2007]数据备份Backup

【链接】 我是链接,点我呀:) 【题意】 在这里输入题意 【题解】 选择的连接肯定是相邻的点对。 那么我们处理出来长度为n-1的数组a 其中a[i-1] = dis[i]-dis[i-1] 那么问题就转化成在a数组中取出不相邻的k个数字。 这k个数字的和要求最小。 那么我们把每个数字都加入到堆中去。 然后对于k个数字。 每次取出堆中的最小值x 累加答案 但是这样做可能不是...

AWCXV 131

BZOJ 1150 CTSC2007 数据备份Backup 堆+贪心

题目大意:给定一个长度为n−1n-1的序列,要求选出kk个不相邻的数使得和最小 费用流显然能跑,而且显然过不去- - 考虑用堆模拟费用流 一个错误的贪心是每次取最小,这样显然过不去样例 我们把【每次取最小】改为【每次选择一个区间取反】,用堆来维护这些区间即可 每次取出最小的区间,然后将两边合并 (比如现在堆里有[1,3][4,4][5,5])这三个区间,我取走了[4,4]并计入答案,那么

世界 2192
上一篇: 1146: [CTSC2008]网络管理Network 树套树,二分,树剖
下一篇: BZOJ 2288: 【POJ Challenge】生日礼物 贪心,堆 BZOJ 1150强化
just_sort
博客等级 码龄11年 2356粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值