hdu 6563 贪心

uniapp - 实现移动端H5微信公众号网页内置浏览器中预览和下载word文档(doc)、excel表格(xls)、ppt文稿、pdf文档等文件,微信内部打开预览和下载到本地详教程,兼容安卓苹果手机 uni-app,微信公众号,h5,移动端,web平台端,网页,网站,Uniapp微信公众号H5网站,内置浏览器下载文档,如何在微信浏览器中预览office文件,word文档,excel文档,pdf文档,ppt文档,office,微信内置浏览器下载文件,下载文件,在微信浏览器里面实现下载任意文件,H5需要在微信浏览器中下载excel文件,UniApp实现网页在微信内置浏览器中下载文件详细教程,安卓点击下载会提示打开浏览器,后端返回流文件,如何解决无法下载文件,跳转至浏览器下载文件,发送到电脑微信,安卓,苹果, 阅读详情

Strength

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 111 Accepted Submission(s): 95

Problem Description
Strength gives you the confidence within yourself to overcome any fears, challenges or doubts. Feel the fear and do it anyway! If you have been going through a rough time and feel burnt out or stressed, the Strength card encourages you to find the strength within yourself and keep going. You have got what it takes to see this situation through to its eventual end. You might also feel compelled to hold space for someone else who is going through a difficult period and needs your strength and support.

Alice and Bob are playing “Yu-Gi-Oh!”, a famous turn-based trading card game, in which two players perform their turns alternatively. After several turns, Alice and Bob have many monsters respectively.
Alice has n and Bob has m monsters under their own control. Each monster’s strength is measured by a non-negative integer si . To be specific, the larger si is, the more power the monster has.
During each turn, for every single monster under control, the player can give a command to it at most once, driving it to battle with an enemy monster (given that opposite player has no monsters as a shield, the monster can directly attack him).
Additionally, the process of the battle is also quite simple. When two monsters battle with each other, the stronger one (i.e. the one with larger si) will overwhelm the other and destroy it and the winner’s strength will remain unchanged. Meanwhile, the difference of their strength will produce equivalent damage to the player who loses the battle. If the player is directly attacked by a monster, he will suffer from the damage equal to the monster’s strength. Notice that when two monsters have the same strength, both of them will vanish and no damage will be dealt.
Right now it is Alice’s turn to play, having known the strength of all monsters, she wants to calculate the maximal damage she can deal towards Bob in one turn. Unfortunately, Bob has great foresight and is well-prepared for the upcoming attack. Bob has converted several of his monsters into defense position,
in which even if the monster is destroyed, he wouldn’t get any damage.
Now you are informed of the strength of all the monsters and whether it is in defense position for each Bob’s monster, you are expected to figure out the maximal damage that could be dealt in this turn.

Input
The first line contains a single integer T ≤ 20 indicating the number of test cases.
For each test case, the first line includes two integer 0 ≤ n, m ≤ 100000, representing the number of monsters owned by Alice and Bob.
In next three lines, the first two lines include n and m integers 0 ≤ si ≤ 109 indicating the strength of the i-th monster, separated by spaces. The last line contains m integers 0 or 1 indicating the position of Bob’s i-th monsters.In other words, 0 represents the normal position and 1 represents the defense position.

Output
For the ith test, output a single line in beginning of “Case i:”, followed by an integer indicating the answer, separated by a single space.

Sample Input
2
4 2
10 10 10 20
5 15
0 1
4 2
10 10 10 20
5 25
0 1

Sample Output
Case 1: 25
Case 2: 15

Source
2018CCPC吉林赛区(重现赛)- 感谢北华大学

题意:

有Alice和Bob两个人在玩游戏王,Alice场上有N个怪兽,Bob有M个怪兽,轮到了Alice回合,问Alice对Bob造成最大的伤害是多少?

思路:

有两个决策的办法。

  1. 不破坏Bob防守态的怪兽,直接攻击他的所有能攻击的怪兽。
  2. 破坏掉Bob防守态的怪兽,再对剩下的怪兽攻击,攻击完所有怪兽之后攻击本人。

两个决策中取最优的就行。

代码:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
struct node
{
    int v,pos;
}a[maxn],b[maxn];
bool cmp(node a,node b)
{
    if(a.pos!=b.pos)
        return a.pos<b.pos;
    return a.v<b.v;
}
int findx(int n,int v)
{
    int l=1,r=n,mid,ans=inf;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(a[mid].v>=v)
        {
            if(a[mid].pos==0)
            {
                ans=mid;
            }
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return ans;
}
int main()
{
    int t,cas=1,n,m;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i].v);
            a[i].pos=0;
        }
        for(int i=1;i<=m;i++)
            scanf("%d",&b[i].v);
        for(int i=1;i<=m;i++)
            scanf("%d",&b[i].pos);
        sort(b+1,b+1+m,cmp);
        sort(a+1,a+1+n,cmp);
        int p=n,q=m;
        ll sum=0;
        ll tmp=0;
        //1 直接攻击它的所有攻击态的
        while(q&&b[q].pos==1) q--;
        while(p&&q)
        {
            if(a[p].v>=b[q].v)
            {
                tmp=tmp+a[p].v-b[q].v;
                p--,q--;
            }
            else break;
        }
        sum=max(tmp,sum);

        //2 先贪心的将它的防御的攻击掉,再攻击剩下的
        p=n,q=m,tmp=0;
        int f=1;
        while(q&&b[q].pos==1)
        {
            int pos=findx(n,b[q].v);
            if(pos==inf)
            {
                f=0;
                break;
            }
            a[pos].pos=1;
            q--;
        }
        int ff=1;
        if(f)
        {
            while(q&&p)
            {
                if(a[p].pos==1) p--;
                else
                {
                    if(a[p].v>=b[q].v)
                    {
                        tmp=tmp+a[p].v-b[q].v;
                        p--,q--;
                    }
                    else
                    {
                        ff=0;
                        break;
                    }
                }
            }
            if(ff)
            {
                while(p)
                {
                    if(a[p].pos==1) p--;
                    else
                    {
                        tmp=tmp+a[p].v;
                        p--;
                    }
                }
            }
            sum=max(sum,tmp);
        }
        printf("Case %d: %lld\n",cas++,sum);
    }
    return 0;
}


模型实战(16)之StrongSort (OSNET)配合YOLOv5、v7、v8 实现多目标跟踪详解 StrongSort (OSNET)配合YOLOv5、v7、v8 实现多目标跟踪详解 阅读详情

相关推荐

原理图转PCB

本文讲述了原理图的编译、原理图转PCB的步骤和易错点。

m0_58083051的博客 3291

HDU中的贪心算法

/j代表价值,f代表重量。

m0_72345017的博客 299

CANape快速上手

文章帮助记录CANape学习过程。

小弱鸡的博客 1万+

HDU 6563 Strength(贪心 双指针)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6563 题目描述比较长,容易读错题 题意: 你有n个怪兽,对方有m个怪兽,每只怪兽有相应的攻击值。两只x和y怪兽pk(一只你的,一只对方的),如果x攻击值>y攻击值,对方将受到x-y伤害(前提是对方的这只怪兽是普通怪兽),同时对方的这只怪兽ko;如果x攻击值==y攻击值,那么这2只怪兽同归于尽;如...

weixin_43918473的博客 397

从零搭建AMESim与Matlab/Simulink联合仿真环境(2024版软件配置详解)

本文详细介绍了2024年最新版AMESim与Matlab/Simulink联合仿真环境的搭建与配置方法。从软件安装顺序、路径设置到编译器配置,逐步指导如何实现高效联合仿真,特别强调了版本兼容性和环境变量设置等关键细节,帮助工程师快速解决常见问题并优化仿真性能。

weixin_42538752的博客 735

第4章--CANoe library开发 - 诊断功能

因为专栏要做的是汽车ECU自动化测试程序,测试的是ECU的诊断和刷新,因此就需要利用CANoe的接口,开发一些方便使用的诊断报文收发函数。

j187067046的博客 1398

hdu 贪心(hdu 2037,hdu 1051,hdu 1050)

hdu 2037 今年暑假不AC (http://acm.hdu.edu.cn/showproblem.php?pid=2037) 比较经典的贪心问题之一,以结束时间排序,如果下一个时间的开始时间大于等于上一个事件结束时间,那么结果就加一。 View Code 1 #include<iostream> 2 #include<cstring> 3 ...

weixin_30530939的博客 262

贝叶斯时空模型-INLA-4

该文章中,会简化数学计算的过程,主要是针对,在有数据的基础上,如何应用贝叶斯时空模型,找出影响因素,绘制时间变化的空间分布预测图。上述中关键一步与前几期介绍的不一样的地方是,我们加入了n.group参数,用来指定年份,先看一下Year有多少年的,然后封装在s.index里面。在前述的内容中,我们介绍了,如何处理空间的数据,利用海拔高度预测降雨量的例子。建立好数据及mesh以后,我们现在写INLA公式,如果不考虑残差项,那就是固定效应,现在我们增加残差项,及空间与时间效应。这里的Mesh设定值为10,20。

学习中 2949

HDU5527 - Too Rich(贪心)

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5527 题目大意: 现在你有P元钱,有10种不同面值的硬币,每种硬币有一定的数量,求用尽量多的硬币凑出P元钱,有可能凑不出。 解题过程: 当初比赛没看这道题,最近才补,看起来挺简单的,实际知道思路上也不难…… 题目分析: 要用尽量多的硬币凑...

weixin_38167363的博客 180

Uni-App 使用极光推送完整指南

Uni-App集成极光推送的完整指南:从注册极光账号到代码实现。包含前期准备(获取AppKey、注册厂商账号)、Uni-App配置(插件导入、初始化代码)、高级功能(角标设置、Java后台接口)及常见问题排查。详细说明了推送监听、registrationID获取、消息接收处理等核心功能实现步骤,并提供两种推送接口示例(按平台推送和统一推送)。适合需要在Uni-App项目中实现推送功能的开发者参考。

cyj0919的博客 429

28_Spring AI 干货笔记之 OpenAI 聊天功能

本文详细介绍了在Spring AI框架中集成OpenAI聊天模型的方法。内容涵盖API密钥配置、通过starter依赖启用自动配置、连接与模型参数的详细设置,并重点说明了运行时选项的动态覆盖机制。文章还深入讲解了多模态处理(图像与音频)、结构化输出、函数调用等高级功能,提供了示例控制器和手动配置指南,并讨论了与OpenAI兼容服务器的适配与推理模型思维链的获取。

在科技的浪潮中,我们寻找着创新的火种,在代码的海洋里,我们编织着智慧的网。腾飞开源,就是这样一个由技术精英汇聚而成的博客平台,我们致力于分享在Java、Python、IoT和人工智能等领域的最新研究成果和实战经验。 在腾飞开源的博客上,你会看到紧跟技术前 1657

Strength(HDU6563+2018年吉林站+双指针瞎搞)

题目链接 传送门 题意 你有\(n\)只怪,每只怪的伤害为\(a_i\),对手有\(m\)只怪,每只怪的伤害为\(b_i\),对手的怪有普通状态和防守状态(普通状态:如果你用攻击力为\(a_i(a_i\geq b_j)\)的怪去攻击对手第\(j\)只怪将会给对手造成\(a_i-b_j\)的伤害;防守状态则不会造成\(a_i-b_j\)的伤害),每只怪只能使用一次,怪一旦死亡就会消失。 用...

di6499的博客 274

手把手教你学Simulink——基于经典滤波器设计的场景:低通滤波器(LPF)的设计与频率响应仿真

滤波器是信号处理领域中非常重要的组件,用于去除不需要的频率成分或者提取有用的频率信息。低通滤波器(Low-Pass Filter, LPF)允许低于某个特定截止频率的信号通过,同时衰减高于该截止频率的信号。在本教程中,我们将学习如何使用设计一个简单的模拟低通滤波器,并对其频率响应进行仿真分析。本文介绍了如何使用设计一个简单的模拟低通滤波器,并通过仿真展示了其应用效果。通过这样的实践,您不仅能够加深对滤波器工作原理的理解,还能掌握利用Simulink进行滤波器设计与仿真的基本技能。

MHD0815的博客 5720

hdu6563 Strength(贪心)

Problem Description Strength gives you the confidence within yourself to overcome any fears, challenges or doubts. Feel the fear and do it anyway! If you have been going through a rough time and feel burnt out or stressed, the Strength card encourages you

。 328

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Strength(贪心)-HDU - 6563

感受 贪心好题贪心好题贪心好题 思路 考虑一个问题,防御状态怪物在什么情况下会攻击呢?考虑一个问题,防御状态怪物在什么情况下会攻击呢?考虑一个问题,防御状态怪物在什么情况下会攻击呢? 如果可以攻击掉所有对手怪物,这才会攻击防御状态怪物。如果可以攻击掉所有对手怪物,这才会攻击防御状态怪物。如果可以攻击掉所有对手怪物,这才会攻击防御状态怪物。 如果有部分对手怪物不能被攻击掉,那么攻击防御状态怪物没有效。如果有部分对手怪物不能被攻击掉,那么攻击防御状态怪物没有效。如果有部分对手怪物不能被攻击掉,那么攻击防御状态怪

weixin_44412226的博客 207

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

2018CCPC 吉林站 I-Strength HDU6563(贪心 + 模拟)

题意:alice和bob玩游戏王,他们各自拥有n张牌和m张怪兽牌,然后给定n张和m张牌他们分别的s[i]值,然后队友bob的m张牌每一张牌还有一个是否置于防御态的标志位。 怪兽之间的对抗遵循以下的原则: 1.当两个怪兽之间力量值不同的时候,力量值高的怪兽会获胜并保持它的力量值然后两张牌之间的力量差值会直接给对手造成伤害。 2.若是bob把某一张牌置于防御状态,那么只有攻击力大于等于他的怪兽才能将它破坏,并且他们之间力量的差值不会给bob造成伤害。 3.alice必须把bob的怪兽清场之后,才能直接攻击bob

forward77 266

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

HDU-1051Wooden Sticks --贪心

Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6563Accepted Submission(s): 2707 Problem Description There is a pile of n w...

weixin_30938149的博客 85

hdu 6560 思维

The Hermit Time Limit: 25000/15000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 69 Problem Description The Hermit stands alone on...

Timeclimber 892

upc 组队赛18 STRENGTH【贪心模拟】

STRENGTH 题目链接 题目描述 Strength gives you the confidence within yourself to overcome any fears, challenges or doubts. Feel the fear and do it anyway! If you have been going through a rough time and feel...

weixin_33730836的博客 623

HDU6560 The Hermit(思维)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6560 参考题解:https://blog.youkuaiyun.com/timeclimber/article/details/96280798 一开始以为是数据结构题,在训练时卡其他题,就没做这道,看了题解后不得不惊叹,原来题目正解,本身可以这么简单,证明也很好理解。 #include <bits/std...

weixin_43918473的博客 416

2018CCPC吉林赛区(重现赛)- 1009 The Hermit

Problem Description Strength gives you the confidence within yourself to overcome any fears, challenges or doubts. Feel the fear and do it anyway! If you have been going through a rough time and feel...

喵喵的小迷弟的博客 360

hdu6560 The Hermit

http://acm.hdu.edu.cn/showproblem.php?pid=6560 这题队友不知道左区间递增,自闭了一整场,然后我一直调计算几何,也不知道他在自闭。。。这场出大问题 由于左区间递增,那么对于i,他向左边最远包含的位置是l,那么对于[l,i-2]都能接收到i的完美信号,因为i-1也必包含他们。。。 #include<bits/stdc++.h> using namespace std; int main(){ int t; scanf("%d",&

binarycopycode 225

2018CCPC吉林赛区(重现赛)- 感谢北华大学 部分题解

A The Fool Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1346 Accepted Submission(s): 535 Problem Description The Fool is numbered 0 – ...

weixin_44941429的博客 1080

HDU6586 String(贪心)

HDU6586 简单贪心题目 满足要求的字典序最小的子序列 优先级1字典序 优先级2位置靠前 因为要求是子序列 很容易想到要记录前缀和后缀和等等。 h[i][j]表示位置i之后的字符(a+‘j’)的数量 pos[i]记录了字符(a+‘i’)的所有位置集合 have[i]表示当前已经有字符(‘a’+i)的数量 有了这三个 就可以开心的贪心了 贪心需要满足的两个条件有: 1.当前选择的位置i后面剩余的...

bestjerry007的博客 219

HDU2037(简单贪心)

点击打开链接 算法导论16.1 #include #include using namespace std; struct node { int s,e; }; bool cmp(node a,node b) { return a.e<b.e; } int main() { int n,i; node q[1000];

West___wind的博客 1734

hdu 1045 贪心求解

Hdu1045 题目大意: 有一个n行n列的地图,其中 '.' 代表空地,可以建造炮台,'x' 代表墙,建造规则是:每两个炮台之间必须有一堵墙,否者这两个炮台就会互相摧毁。现在输入一张这样的地图,要你计算最多可以建造多少炮台? 解题思路: 根据地图,得到一张新的数字地图,这张数字地图的构建方法是: 大小和原地图一样, 计算原地图的每一个 ' . ' 所在行列中有多少个 ‘ . ’,并将...

wangmengfuu的博客 1009
上一篇: hdu 6560 思维
下一篇: 2019牛客暑期多校训练营(第一场)A Equivalent Prefixes
Timeclimber
博客等级 码龄9年 25粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值