Codeforces799C. Fountains

YOLOv11涨点改进 | Neck改进篇 | YOLOv11引入 BiFPN双向特征金字塔网络,显著提升了多尺度特征融合效率 本文介绍了基于BiFPN特征融合模块优化的YOLOv11目标检测模型。BiFPN通过双向跨尺度连接和加权特征融合机制,显著提升了多尺度特征融合效率。该方法在COCO数据集上实现了55.1AP的检测精度,同时大幅降低计算成本(减少13-42倍FLOPs)。文章详细解析了BiFPN模块结构、核心代码实现方法,并提供了YOLOv11-BiFPN配置文件的修改指导,为计算机视觉领域提供了一种高效的目标检测解决方案。 阅读详情

Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes between the types are allowed.

Help Arkady to find two fountains with maximum total beauty so that he can buy both at the same time.

Input
The first line contains three integers n, c and d (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100 000) — the number of fountains, the number of coins and diamonds Arkady has.

The next n lines describe fountains. Each of these lines contain two integers bi and pi (1 ≤ bi, pi ≤ 100 000) — the beauty and the cost of the i-th fountain, and then a letter “C” or “D”, describing in which type of money is the cost of fountain i: in coins or in diamonds, respectively.

Output
Print the maximum total beauty of exactly two fountains Arkady can build. If he can’t build two fountains, print 0.

Examples
input
3 7 6
10 8 C
4 3 C
5 6 D
output
9
input
2 4 5
2 5 C
2 1 D
output
0
input
3 10 10
5 5 C
5 5 C
10 11 D
output
10
Note
In the first example Arkady should build the second fountain with beauty 4, which costs 3 coins. The first fountain he can’t build because he don’t have enough coins. Also Arkady should build the third fountain with beauty 5 which costs 6 diamonds. Thus the total beauty of built fountains is 9.

In the second example there are two fountains, but Arkady can’t build both of them, because he needs 5 coins for the first fountain, and Arkady has only 4 coins.

遇事不决 先膜来神

来神还是强啊

这题如果你在用C和D各买一个就很简单,sort之后挑一个能买的最贵的。
然后还有两种情况就是C里面买两个 或者D里面买两个,这怎么办呢。由于是挑两个,那么如果你挑了一个之后 另一个能挑的区间就确定了,那么 区间查询。。。最大值。。。嗯 。。线段树。。
这里还有个细节处理,是边更新边查询,而不是一次性更新完然后便利查询,这样可以防止自己访问自己2333自己体会一下

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<map>
using namespace std;

//thanks to pyf ...

#define INF 0x3f3f3f3f
#define CLR(x,y) memset(x,y,sizeof(x))
#define mp(x,y) make_pair(x,y)
typedef pair<int, int> PII;
typedef long long ll;

const int N = 1e6 + 5;

struct
{
    int l, r;
    int Max;
} t[N * 4];
ll a[N];
ll cost_a[N];
int cnt_a[N];
int cnt_b[N];
ll b[N];
ll cost_b[N];
void build(int l, int r, int step)
{
    t[step].l = l;
    t[step].r = r;
    t[step].Max = -1;
    if (l == r)
        return;
    int mid = (l + r) / 2;
    build(l, mid, step * 2);
    build(mid + 1, r, step * 2 + 1);
}
void push_up(int step)
{
    t[step].Max = max(t[step * 2].Max, t[step * 2 + 1].Max);

}
void update(int x, int val, int step)
{
    if (t[step].l == t[step].r)
    {
        t[step].Max = max(t[step].Max , val);
        return ;
    }
    int mid = (t[step].l + t[step].r) / 2;
    if (x <= mid)
        update(x, val, step * 2);
    else
        update(x, val, step * 2 + 1);
    push_up(step);
}
int query(int l, int r, int step)
{
    if (t[step].l == l && t[step].r == r)
        return t[step].Max;
    int mid = (t[step].l + t[step].r) / 2;
    if (r <= mid)
        return query(l, r, step * 2);
    else if (l > mid)
        return query(l, r, step * 2 + 1);
    else
        return max(query(l, mid, step * 2), query(mid + 1, r, step * 2 + 1));
}
int main()
{
    int n, c, d;
    while (cin >> n >> c >> d)
    {
        CLR(cnt_a, 0);
        CLR(cnt_b, 0);
        int cnt_c = 0;
        int cnt_d = 0;
        int MaxC = 0;
        for (int i = 0; i < n; i++)
        {
            int x, y;
            string s;
            cin >> x >> y >> s;
            MaxC = max(MaxC, y);
            if (s[0] == 'C')
                a[cnt_c] = x, cost_a[cnt_c++] = y, cnt_a[x]++;
            else
                b[cnt_d] = x, cost_b[cnt_d++] = y, cnt_b[x]++;
        }
        ll ans = -1;
        ll res1 = -1, res2 = -1;
        for (int i = 0; i < cnt_c; i++)
        {
            if (cost_a[i] <= c)
                res1 = max(res1, a[i]);
        }
        for (int i = 0; i < cnt_d; i++)
        {
            if (cost_b[i] <= d)
                res2 = max(res2, b[i]);
        }
        if (res1 != -1 && res2 != -1)
            ans = res1 + res2;
        MaxC = max(MaxC,max(c,d));
        build(1, MaxC+10, 1);
        for (int i = 0; i < cnt_c; i++)
        {
            ll res = -1;
            if (c > cost_a[i])
                res = query(1, c - cost_a[i] , 1);
            update(cost_a[i], a[i], 1);
            if (res == -1)
                continue;
            ans = max(ans, res + a[i]);
        }
        build(1, MaxC + 10, 1);
        for (int i = 0; i < cnt_d; i++)
        {
            ll res = -1;
            if (d > cost_b[i])
                res = query(1, d - cost_b[i] , 1);
            update(cost_b[i], b[i], 1);
            if (res == -1)
                continue;
            ans = max(ans, res + b[i]);
        }
        if (ans == -1)
            cout << 0 << endl;
        else
            cout << ans << endl;
    }
    return 0;
}
Python入门实战:Python生物信息学编程基础 本文旨在为生物学背景的研究人员和对生物信息学感兴趣的程序员提供一个全面的Python生物信息学编程入门指南。我们将从Python基础知识开始,逐步深入到生物信息学特定的工具和技术,最终达到能够独立开发生物信息学分析程序的水平。Python编程基础生物信息学常用数据结构和算法DNA和蛋白质序列分析基因组数据处理生物信息学数据可视化Biopython库的使用实际项目案例背景介绍:概述文章目的、范围和预期读者核心概念与联系:介绍Python和生物信息学的基本概念。 阅读详情

相关推荐

FreeRTOS实战:如何避免HAL_Delay在高优先级中断中的坑(附TIM6配置指南)

本文深入剖析了在STM32 FreeRTOS项目中,于高优先级中断内调用HAL_Delay函数导致系统假死的根本原因——SysTick时基被FreeRTOS占用且优先级最低。文章提供了治本方案:通过配置TIM6作为独立且最高优先级的HAL时基,实现与FreeRTOS系统心跳的解耦,并附上详细的CubeMX配置与代码移植指南,确保系统实时性与稳定性。

weixin_29230059的博客 64

codeforces 799C Fountains

Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: co

uh_eng的博客 1101

完美解决 mysql 报错ERROR 1524 (HY000): Plugin ‘mysql_native_password‘ is not loaded

mysql 报错ERROR 1524 (HY000): Plugin 'mysql_native_password' is not loaded

xiaohua616的博客 4万+

【codeforces 799C】Fountains

【题目链接】:http://codeforces.com/contest/799/problem/C 【题意】 你有两种不同的货币; 余额分别为c和d 然后有n种商品; 每种商品只能由两种货币中的某一种购买; (且每件商品都有它的美丽值和对应货币的花费) 让你用这两种货币的余额严格买两件商品; 要求让美丽值最大; 输出最大的美丽值; 【题解】...

AWCXV 129

如何产生ATPG IR-drop分析波形文件(DFT)

摘要:本文介绍了生成VCD波形的流程与要求,主要用于后端进行IR-drop分析。生成过程分为ATPG shift和speed ATPG capture两部分,分别对应不同的输入要求、模式设置和仿真参数。

murphyrong的博客 870

Pspice开关电源仿真:从零实现反激式电源设计实战案例

通过Pspice仿真工具,手把手实现反激式开关电源的设计与优化,深入剖析关键参数设置与波形分析,帮助掌握Pspice在电源开发中的实际应用技巧。

weixin_35756690的博客 1155

CodeForces - 799C Fountains (枚举+线段树)

CodeForces - 799C  Fountains   题意:一个人要建造两个喷泉,有两种货币,每个喷泉的花费只能使用一种货币,每个喷泉都有一定的美丽值,给出喷泉的个数及两种货币的总量,每个喷泉的美丽值和花费,输出建造两个喷泉时能达到的最大美丽值,如果不能建造两个喷泉,输出0  思路:总共分三种情况:用C货币建造一个用D货币建造一个,用C货币建造两个,用D货币建造两个,第一种情况简单,分别求...

GYH0730的博客 788

PRIDE数据库20年:2025更新

PRoteomics IDEntifications (PRIDE)数据库(https://www.ebi.ac.uk/pride/)是全球领先的基于质谱(MS)的蛋白质组学数据存储库,也是ProteomeXchange联盟的创始成员之一。本文总结了过去3年中PRIDE资源及相关工具的发展情况。提交到PRIDE存档的数据集数量平均每月达到约534个。主要得益于基础设施的持续改进,如用于超大数据集的新文件传输协议(Globus)、新的数据重新提交流程以及自动数据集验证过程。

多组・学・多组学 2062

codeforces 799C Fountains 线段树

题意:购买喷泉有两种方式,用硬币或砖石,都有对应的价格,和美丽度。给定初始的硬币和砖石数,要求买两个喷泉且美丽度之和最大。如果不能买两个输出-1 思路:三种情况:两种都用C或D,CD各一个。C,D各一个只要选择能够买得最大美丽度的喷泉。两种都用C或D,选择了一个之后,另外一个能够买得范围就确定了。 #include #include #include #define ll long long

chen_minghui的博客 584

MODTRAN5.2.1安装配置

MODTRAN5.2.1安装配置

Home 4253

16、天文时间序列分类:基于人工神经网络的研究

本研究探讨了基于人工神经网络的天文时间序列分类方法,重点比较了MLP、LSTM和CNN等模型在BRITE和开普勒K2数据集上的表现。研究发现LSTM不适用于此类数据,而结合特征提取与PSO超参数优化的多层感知器(MLP)在开普勒K2数据上实现了98.55%的二分类准确率。通过精细的数据预处理和高置信度样本选择,显著提升了分类性能。研究成果为恒星变异性识别提供了高效工具,并对天文学与机器学习交叉领域具有重要参考价值。

pz8901234的博客 112

Fountains CodeForces - 799C

Fountains CodeForces - 799C 题意:给n,c,d代表喷泉个数,拥有硬币和砖石个数。接下来n行有b,p,c代表改喷泉美丽指数和价格CD代表用什么当作货币。 思路:只存下价格小于c,d的喷泉。进行排序,选择c+d,c+c,d+d中值最大的。这里直接n^2的搜索,就加了一点剪枝,卡过去了。 #include&lt;iostream&gt; #include&lt;cst...

DeathYmz的博客 448

智能车图像处理3-入门级分析2 ---直道冲刺

PS :入门级文章适合新手,如果已经有基础可以去看进阶篇文章。

taiyuezyh的博客 4306

Codeforces 799C Fountains 枚举+二分

点击打开链接 题意:n件物品,有金币C和砖石D n,c,d 两件物品为CC,按花费排序,防止重复,则枚举两件中花费高的那一件p[x], 于是剩下一件的选择范围限定在前[i-1]件内,剩下的钱c-p[x]递减,用一个游标pos(或者二分)记录最后一个小于c-p[x],并维护前缀min[i-1,pos]内最大能取到的价值即可 #include using namespace std; t

Masamiiiiii 953

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Codeforces 799C Fountains 题解

Codeforces 799C题解

DarkoDu的博客 1229

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

CodeForces - 799C Fountains

Fountains 题 意:Alice想建两座喷泉,现在有n座喷泉,每座喷泉的美丽值为pi,价格为ci个coins或者di个diamonds。两种货币不可以互换。现在Alice有c个coins和d个diamonds。问alice建造的两座喷泉最大的美丽值为多少? 数据范围: 2&lt;=n&lt;=1e5 0&lt;=c,d&lt;=1e5 1&lt;=ci,di&lt;=1e5 输入...

子灬丶逾 323

efm32 入门.pdf

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

CodeForces-799C Fountains

有三种情况,选一个C和一个D,或者选两个C或D C,D各一个的时候好找,两个C或D的时候用线段树维护查讯,取这三种情况的最大值 两个C或D的时候直接暴力加一些优化也可以过 线段树方法: #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;algorithm&gt; #inc...

wl16wzl的博客 306

CodeForces - 799C Fountains

CodeForces - 799C Fountains 这是一个一看就知道我见过,但是我还是不会做的题,找了个题解辛辛苦苦一边理解一边抄的弄了半天,一跑……第一个测试样例就不对,气死了,抄了一个交上了,写完了这篇我再看看题的。 Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are ...

mandiheyanyu的博客 227

Codeforces 799C. Fountains

C. Fountains time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There ar

LuRiCheng的博客 830

【CodeForces】【二分】799 C Fountains

【题目】http://codeforces.com/problemset/problem/799/C 【题意】现在有n件物品,有c枚金币和d个砖石 n,c,d&lt;=1e5,每件物品有价值和花费(类型为c或者d),现在要购买恰好两件物品,并使得获得价值最大。问最大的价值,如果买不到,输出0。 【思路】 能买到的话,只有3种情况:1:一个物品是用金币买的,另一个是用钻石买的;       ...

swqeaaa的博客 202

codeforces 799 C. Fountains(二分+思维)

题目链接:http://codeforces.com/contest/799/problem/C 题意:要求造2座fountains,可以用钻石,也可以用硬币来造,但是能用的钻石有限,硬币也有限,问能造出最大的美丽值为多少。 题解:显然如果两个fountains分别用钻石和硬币来造的话就直接取两种类型里满足条件的最大值即可。 如果选的是同类的话,先按照数量来排序,然后那一个数...

awow80285的博客 233

Fountains CodeForces - 799C (二分)

Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There arenavailable fountains, for each fountain its beauty and cost are known. There are two types of money in the game: co...

zx93的博客 288

CodeForces 799C Fountains(树状数组)

树状数组 把满二叉树的形状稍微改变一下,变成下面的图形。 用C[i]代表子树的叶子结点的权值之和。以求和举例 1=(001) C[1]=A[1]; 2=(010) C[2]=A[1]+A[2]; 3=(011) C[3]=A[3]; 4=(100) C[4]=A[1]+A[2]+A[3]+A[4]; 5=(101) C[5]=A[5]; 6=(1...

H4ppyD0g的博客 543

Fountains 【CodeForces - 799C】【线段树】

题目链接 这道题一开始让我懵了好一会,原来是要恰好两座喷泉才可以计算最优解的说。 有如下N个方案,每个方案有那么些值,譬如说按照输入顺序分别是:美观度、价格、货币的种类。我们要求的是这样子的情况,我们有两种货币各自C、D个,求的是以手上的钱,最多的美观度的和是多少? 那么,不如就直接去求,因为货币数量最多达到1e5,所以,我们可以直接用线段树的方式来解这道题,区间上是该种货币的价...

既然弱小,就只顾变强就是了 251
上一篇: Weak Pair HDU - 5877
下一篇: Codeforces455C. Civilization
OneDay_pyf
博客等级 码龄10年 6粉丝 35原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值