首页 > 其他分享 >[ABC344G] Points and Comparison

[ABC344G] Points and Comparison

时间:2024-03-22 16:57:11浏览次数:20  
标签:Comparison le 最大值 小球 Points ABC344G

题意

给定 \(n\) 个球,每个球有颜色 \(C_i\),价值 \(V_i\)。

你需要删除恰好 \(k\) 个小球,使得剩余的小球没有相邻颜色相同且价值最大。

求这个价值。

\(k \le 500, n \le 2 \times 10 ^ 5\)

Sol

考虑一个平凡的 dp。

\(f_{i, j}\) 表示最后剩了 \(i\),当前留下了 \(j\) 个的最大价值。

\[f_{i, j} = \max_{p < i, C_p \neq C_i} f_{p, j - 1} + V_i \]

注意到对于每一个 \(j\) 来说,可以有贡献的 \(i\) 当前仅当满足:\(j \le i, i \le j + k\)。因此状态数为 \(nk\)。

考虑加速转移,容易想到先枚举 \(j\),然后在转移的过程中更新 \(j - 1\) 对当前的答案。

记录 \(j - 1\) 的最大值、最大值的颜色、次大值即可。

标签:Comparison,le,最大值,小球,Points,ABC344G
From: https://www.cnblogs.com/cxqghzj/p/18089910

相关文章

  • 《Distributed_Storage_Codes_With_Repair-by-Transfer_and_Nonachievability_of_Inte
    论文5个部分,本篇主要是针对3-14日组会中,懂和不懂的地方进行记录。论文部分:①RAID(待补充)②DC(datacollector)数据收集器+重建节点所有的这些系统,最基本的是要保证“DC”功能,也就是数据收集;在这个基础上,再保证,假如某节点出问题,能否修复;再研究,怎么修复代价最小,代价又分很多,有修......
  • ABC344G 笔记
    题意给定\(N\)个二维平面上的点\((X_i,Y_i)\)与\(Q\)组询问,每组询问给出一条直线\(Y=A_iX+B_i\),问有多少个点在直线上方(或者在直线上)。也就是询问有多少个\((X_i,Y_i)\),满足\(Y_i\geA_j\timesX_i+B_j\)。题解首先这个式子是\(A\timesX+B\leY\),移项......
  • ABC344G 题解
    ABC344G题解给定平面上\(n\)个点和\(q\)条直线,问对于每条线,有多少点在它上方。形式化的,对于直线\(y=ax+b\)统计有多少点\((x,y)\)满足\(y\geax+b\),即\(-ax+y\geb\)。故我们可以将所有点按照\(-ax+y\)排序,从而利用二分简单的得出结果。但是我们显然不可能暴力进......
  • Codeforces 1455E Four Points
    首先确定每个点最后走到的是哪一个点。这部分可以枚举全排列。假设左上角的点为\((x_0,y_0)\),右上角的点为\((x_1,y_1)\),左下角的点为\((x_2,y_2)\),右下角的点为\((x_3,y_3)\)。令最终的点为\((x'_0,y'_0)\),以此类推。那么最终的答案就是\(\sum\limits_{i=0}^3|......
  • 11 .Codeforces Round 891 (Div. 3)E. Power of Points(推公式+前缀和优化)
    E.PowerofPoints题解参考#include<bits/stdc++.h>#defineintlonglong#definerep(i,a,b)for(inti=(a);i<=(b);++i)#definefep(i,a,b)for(inti=(a);i>=(b);--i)#define_for(i,a,b)for(inti=(a);i<(b);++i)#definepii......
  • 149. Max Points on a Line
    149.MaxPointsonaLineGivenanarrayof points where points[i]=[xi,yi] representsapointonthe X-Y plane,return themaximumnumberofpointsthatlieonthesamestraightline.Example1:Input:points=[[1,1],[2,2],[3,3]]Output:3E......
  • Go - floating points
    Notethatthere’saninfinitenumberof realvaluesbetweenmath.SmallestNonzeroFloat64(thefloat64minimum)and math.MaxFloat64(thefloat64maximum).Conversely,thefloat64typehasafinite numberofbits:64.Becausemakinginfinitevaluesfitinto......
  • Comparison between IPQ9574 and IPQ9554 | MLO EHT Solution Unveils the WiFi 7 CPU
    ComparisonbetweenIPQ9574andIPQ9554|MLOEHTWiFi7QualcommSolutionUnveilstheWiFi7CPUforIndustrialApplications-AlderSeriesWi-Fi7elevateswirelessexperiencesandwillaccelerateemergingusecaseswithitsextremedataspeedsandconsis......
  • UVA10295 Hay Points 题解
    题目大意:给你\(n\)个单词,每一个单词的值为\(v_i\),让你求出在一个文章段落里的出现过的单词的值之和。思路:可以用STL库中的map来存储一个单词的值,最后在处理的时候可以直接累加。附上你们最期待的代码:#include<bits/stdc++.h>usingnamespacestd;map<string,int......
  • DIANN-MSstats groupComparison Issue: undefined columns selected
    1.Whaterrormessagedidyouencounter?Errorin`[.data.frame`(as.data.frame(comparisons),,cols):undefinedcolumnsselected 2.Howdidyousolvetheerror?install.packages("lme4",type="source") 3.Whatarethepos......