Codeforces Round #424 (Div. 2)C. Jury Marks 暴力 D. Office Keys 二分 E. Cards Sorting 树状数组

C++并发与内存池实战:线程安全队列+对象池+基准对照,可跑源码 面向C++并发与性能练习的离线资源包。用C++17实现线程安全多生产者多消费者队列、固定块内存池与对象池,并与new/delete做短基准对照;另附循环展开与可选向量化对比,无SIMD指令也能在普通x86上运行。含多线程正确性测试,可离线用g++编译。MIT。作者blog.csdn.net/mtl1994 立即下载

C:http://codeforces.com/contest/831/problem/C。

题意:给两个序列a和b

有一个初始值,不断的加ai,要求是在加的过程中b的所有值都出现过,求这样满足条件的初始值有几个。

崩了,这么水的暴力竟然没想出来??

先把所有的b值标记出来,随便选一个b,暴力放到某一个a后面,这样就可以直接找出原序列,看看b数组里的值是不是都出现过,如果出现过则这个序列满足条件

#include<bits/stdc++.h>
using namespace std;
int a[2005],b[2005],c[2005];
int book[20000005];
map<int ,int >p;
int pian=10000000;
int main()
{
    int i,j,n,k,ans=0;
    cin>>k>>n;
    for(i=0;i<k;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    cin>>b[i],book[b[i]+pian]=1;
    book[b[0]+pian]=0;
    for(i=0;i<k;i++)
    {
        int now=b[0],t=0;
        for(j=i;j>=1;j--)
        {
            now-=a[j];
            if(book[now+pian])
            {
                book[now+pian]=0;
                t++;
            }
        }
        now-=a[0];
        int now2=b[0];
        for(j=i+1;j<k;j++)
        {
            now2+=a[j];
            if(book[now2+pian])
            {
                book[now2+pian]=0;
                t++;
            }
        }
        if(t==n-1)
        {
            if(!p.count(now))
            ans++,p[now]++;
        }
        for(j=1;j<n;j++)
        book[b[j]+pian]=1;
    }
    cout<<ans<<endl;
    return 0;
}

D:http://codeforces.com/contest/831/problem/D D

题意:有一群人和一堆钥匙的坐标,每个人都要拿一个钥匙去指定地点,每个钥匙只能被拿一次,求最小化拿钥匙的最长距离值

刚开始看错题意,以为是求所有人拿钥匙的最小路程总和,,,,想着二维dp【i】【j】表示前i个人从前j把钥匙里拿的最小花费,不知道对错,,没过样例

发现是求最小化最长距离

那就是很明显的二分了,实现排序,因为对于一个小的点的钥匙,如果小的点的人不拿,后面的人会更难拿,check o(n)扫一遍

#include<bits/stdc++.h>
using namespace std;
long long a[2005],b[2005];
long long n,k,p;
int cmp(long long u,long long v)
{
    return u<v;
}
int check(long long x)
{
    int i;
    int now=0;
    for(i=0;i<n;i++)
    {
        while(abs(b[now]-a[i])+abs(p-b[now])>x)
        {
            now++;
            if(now>=k)
                return 0;
        }
        now++;
    }
    return 1;
}
int main()
{
    int i,j,x;
    cin>>n>>k>>p;
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n,cmp);
    for(i=0;i<k;i++)
    cin>>b[i];
    sort(b,b+k,cmp);
    long long le=0,ri=0x3f3f3f3f3f3f3f3f,mid,ans;
    while(le<=ri)
    {
        mid=(le+ri)>>1;
        if(check(mid))
        {
            ans=mid;
            ri=mid-1;
        }
        else
            le=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}
E:http://codeforces.com/contest/831/problem/E  E
题意:有一堆牌,不断的拿第一张,如果这张牌是此时最小的牌,则拿掉,如果不是,则放到牌底

树状数组,每个点刚开始为1,拿走的置为0,无论怎么换,其实顺序是不变的,特殊修改一下即可,对于数值相同的牌,要有一个拿的顺序,由前面拿完(数值比他小且紧挨着的)后的位置决定,可以在排序的时候修改一下cmp。

#include<bits/stdc++.h>
using namespace std;
long long n,f[200000];
long long sum(int x)
{
    long long sum=0;
    while(x)
    {
        sum+=f[x];
        x-=x&-x;
    }
    return sum;
}
void add(int x,int a)
{
    while(x<=n)
    {
        f[x]+=a;
        x+=x&-x;
    }
    return ;
}
vector<int> w[100005];
int pre=1;
long long ans=0;
int cmp(int u,int v)
{
    int u1=(u-pre+n)%n;
    int v1=(v-pre+n)%n;
    return u1<v1;
}
int main()
{
    cin>>n;
    int i,j,a;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        w[a].push_back(i);
        add(i,1);
    }
    for(i=1;i<=100000;i++)
    {
        if(w[i].size())
        {
            sort(w[i].begin(),w[i].end(),cmp);
            pre=w[i][w[i].size()-1];
        }
    }
    pre=0;
    for(i=1;i<=100000;i++)
    {
        for(j=0;j<w[i].size();j++)
        {
            int now=w[i][j];
            if(now>pre)
            {
                ans+=sum(now)-sum(pre);
            }
            else
            {
                ans+=sum(n)-sum(pre)+sum(now);
            }
            pre=now;
            add(now,-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}




【03】海康MVS V4.3.0 ——安装教程、查看示例、库、头文件、开发指南 海康威视MVS机器视觉软件安装与使用指南:首先从官网下载MVS 4.3.0安装包,默认设置完成安装。安装后可在Development目录查看示例代码、开发文档及头文件,支持C++/C#/Python等多语言开发。软件内置虚拟相机功能,通过工具菜单添加虚拟设备后即可模拟真实相机操作,支持中英文界面切换、参数调节(曝光/增益等)及图像采集功能。虚拟相机虽仅能显示预设图像,但完整保留了参数调节功能,适合开发者进行功能测试。 阅读详情

相关推荐

半导体设备上位机开发:我的经验与新人指导

半导体设备上位机开发是一项复杂而富有挑战性的工作,需要扎实的技术基础和丰富的经验。如果你对半导体设备上位机开发感兴趣,欢迎随时与我交流,我会尽力帮助你!

qq_43518667的博客 2748

codeforce 939D. Love Rescue(dfs+贪心)

D. Love Rescuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took ...

gyr 518

TC3xx系列LMU与SPR实战:将关键算法从Flash搬移至PSPR提升5倍执行效率

在实际电机控制项目中,通过将FOC算法全部迁移到PSPR,我们不仅将执行时间从56μs降至11μs,还将最坏情况下的时间偏差控制在±0.3μs以内。实测数据:在TC397上执行Flash中的32位浮点矩阵乘法,平均每条指令需要8.7个周期,而同样的代码在PSPR中仅需1.2个周期。传统开发中,工程师往往将所有代码放在Flash中运行,这相当于让F1赛车在乡村公路上行驶。迁移后不仅平均执行时间缩短,更重要的是时间抖动从±15%降低到±2%以内,这对闭环控制系统至关重要。不是所有代码都适合迁移到PSPR。

weixin_31421613的博客 299

D - Love Rescue CodeForces - 939D

Valya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took offense at her boyfriend because he came to her in t-shirt with lettering that differs from lettering on her pullove...

闭上左眼看世界的博客 345

别再死磕RD算法了!用MATLAB手把手复现SAR后向投影(BP)成像(附完整代码与避坑点)

本文详细介绍了如何使用MATLAB实现合成孔径雷达(SAR)后向投影(BP)成像算法,突破传统RD算法在大斜视和复杂轨迹场景中的局限。通过完整的代码示例和避坑指南,帮助读者掌握BP算法的核心原理、内存优化策略和并行计算技巧,提升SAR成像精度与效率。

weixin_30908103的博客 301

数据助力行业发展:BJTU-RAO转向架数据集介绍

BJTU-RAO转向架数据集是完全公开的,何研究人员皆可以通过后文的下载链接免费下载数据,且在标注数据来源的前提下,研究人员可以自由使用BJTU-RAO转向架数据集。因此,聚焦各类列车转向架传动系统在途安全保障新技术研究和新算法开发,实现牵引电机、驱动齿轮箱和轴箱等关键部件的实时状态监测与智能故障诊断,对保障列车安全可靠运行具有重要的现实意义。BJTU-RAO转向架数据集包含51种健康状态的样本,涵盖正常状态、部件级单一故障、部件级复合故障以及系统级关联复合故障,数据量达116GB。

2401_88870554的博客 3517

Love Rescue CodeForces - 939D

http://codeforces.com/contest/939/problem/D 每次可以找一个字母对 (c1,c1) 以后这两个字符就可以随便相互转换 用最少的对数将两个字符串变得一样 且这些转换具有传递性 其实可以看做一个最小生成树 如果两字符串对应位置不相等 就当作在图上 有两个字符对应的点 两点之间有一条边 因为有传递性 所以我们要的就是用最小代价将图连通 #include ...

sunyutian1998的博客 274

安装了anaconda,pycharm导入numpy时提示没有该包(模块)?

**问题详情:**我安装了anaconda,在利用Pycharm学习numpy这个库的时候,导入numpy这个包的时候提示我没有nummpy这个模块:No module named numpy.如下图所示。 应该说安装了Anaconda,里边就自带了numpy这个库,就应该能够使用。我一个新手怎么搞得懂呢?于是网上查了查找到了一个解决办法,说是我项目的解释器应该设置为Anaconda安装目录下的python.exe,而不应该是系统自带的:https://blog.csdn.net/aanndd77/art

qq_39820505的博客 1万+

Codeforces-939D:Love Rescue(并查集)

D. Love Rescuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValya and Tolya are an ideal pair, but they quarrel sometimes. Recently, Valya took ...

Mitsuha_的博客 722

告别JavaScript!C#通过WebAssembly在浏览器中实现“原生级“性能

C# + WebAssembly:前端开发的革命性替代方案 摘要:本文探讨了C#通过WebAssembly取代JavaScript开发前端应用的新趋势。文章分析了JavaScript的局限性(弱类型、回调地狱等),并详细介绍了C#+WebAssembly组合的优势:强类型系统、高性能、多线程支持和代码重用。技术实现方面,阐述了C#通过Mono/.NET编译为WebAssembly字节码的原理,重点介绍了Blazor框架的两种模式。文章还提供了实战指南,包括项目创建、多线程配置,以及一个与ChatGPT AP

墨夶的博客 954

【AUTOSAR-CanNM】-3.1-如何让ECU发出的首帧是NM帧(Tx Nm报文先于Tx App应用报文发出)

如何让ECU发出的首帧是NM帧(Tx Nm报文先于Tx App应用报文发出)

「汽车电子助手」的博客 4732

Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes

A. Ostap and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On the way to Rio de Janeiro Ostap

jerans的博客 1289

C#【通用方法】字节数组添加、移除、获取的方法类(妙用List<byte>,开发中常用)

C#【通用方法】添加移除字节的方法类(妙用List,开发中常用)

星Yeah 的博客 3363

Gym - 101128C Canvas Painting 逆向思维

https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337 刚开始读错题意,以为是不变序列,就想着区间dp但数据量肯定会t,,,没想到什么优化方法就放下了,后来队员发现序列是可变的。。。。任意的。。。。。 想着先排序在布拉布拉布拉,一直都没有逆向思维想到哈夫曼。只怪数据结构没认真听啊。。。。 想到哈夫

jerans的博客 947

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

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

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

CodeForces - 361D Levko and Array二分加dp

D. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of inte

jerans的博客 840

WINCC7.3破解文件

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

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞

C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arkady plays Gardenscapes a lot. Arkady wants

jerans的博客 811

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon

D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output PolandBall has such a convex poly

jerans的博客 727

B. The Meeting Place Cannot Be Changed

B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Byt

jerans的博客 697

Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//

C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service

jerans的博客 685

Beautiful numbers CodeForces - 55D 数位dp

D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is

jerans的博客 677

Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造

C:http://codeforces.com/contest/828/problem/C 题意:有一个字符串,你知道他的一些子串所在的位置,求符合条件的字典序最小的原串 因为已知的数据较大,还存在较多重复的部分,直接暴力不可行 可以记录原串每个位置的下一个没确定出来的字符的位置(记住next【i】),优化后可以过,时间较长 #include #define eps 1e-9 #defin

jerans的博客 672

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

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

jerans的博客 664

Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率dp

D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bad Luck Island is inhabited by thre

jerans的博客 649

Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom

人生的第一次div.1 掉分 QAQ A - Planning http://codeforces.com/contest/853/problem/A 贪心,排个序,优先安排花费大的,用模拟链表实现的 #include #define eps 1e-9 #define PI 3.141592653589793 #define bs 1000000007 #define bsize

jerans的博客 627

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

jerans的博客 609

Codeforces Round #390 (Div. 2//754D. Fedor and coupons

D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The s

jerans的博客 583
上一篇: Codeforces Round #422 (Div. 2) C. Hacker, pack your bags! 思维排序或二分
下一篇: You Are the One HDU - 4283 区间dp
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值