codeforces pumping 1909g lemma

Codeforces Round 902 (Div. 1, based on COMPFEST 15 - Final Round) A~D

A. Helmets in Night Light 首先注意到一个关键性质 \(b_i \geq 1\),这就意味着当我们花 \(p\) 的代价解锁了 \(b_i\) 最小的后,仅凭接下来的“连锁反应”就能解锁全部的点。注意到我们“连锁反应”的一定是按 \(b_i\) 从小到大排序后的一段前缀(因为 ......
Round Codeforces COMPFEST Final based

Codeforces Round 902 (Div. 2) (CF1877) B、C、D 题解

B 题目大意 你要传话给 \(n\) 个人,每传一下话需要花费 \(p\) ,当一个人被传话后,他可以最多传给 \(a_i\) 个人,每次花费 \(b_i\) 。问把话传给 \(n\) 个人的最小花费。 分析 首先传给第一个人只少要 \(p\) 下来贪心,每次让花费最小、且能够传话的人去传话。 考虑 ......
题解 Codeforces Round 1877 902

Codeforces Round 902 Div. 2 - A B C D

目录A. Goals of VictoryB. Helmets in Night Light 传送门 A. Goals of Victory 对给定 n - 1 组队伍的净得分求和取负即为最后一组队伍的净得分 B. Helmets in Night Light 赛时想法假了,赛后更正 对所有人按照传 ......
Codeforces Round 902 Div

Codeforces Round #902 (Div.1)

A 注意到 \(a_i\ge 1\),因此我们先花 \(p\) 的代价买下 \(b\) 最小的,然后一定可以一直用当前可能的最小代价买下后续的人。不难发现这一定是最优的方案。 只需要将序列排序或者用 std::multiset 来维护。单组数据时间复杂度 \(O(n\log n)\)。 https: ......
Codeforces Round 902 Div

【题解】CodeForces-1874/1875

CodeForces-1875A Jellyfish and Undertale 一定是等待降到 \(1\) 或者能补满到 \(a\) 时才使用工具,依题意模拟即可。 提交记录:Submission - CodeForces CodeForces-1874A Jellyfish and Game 这 ......
题解 CodeForces 1874 1875

Codeforces Round 901 (Div. 2) D. Jellyfish and Mex (DP)

Codeforces Round 901 (Div. 2) D. Jellyfish and Mex //思路:对于大于mex的数不做处理,把0删完为结束 //dp[j]为mex更新到j所需要的最小花费 //用mex=i时更新到j,转移方程为 dp[j] = min(dp[j], dp[i] + i ......
Codeforces Jellyfish Round 901 Div

Codeforces Round 900 (Div. 3) E. Iva & Pav (位运算)

Codeforces Round 900 (Div. 3) E. Iva & Pav //思路:10^9转换为2^32上的位,进行位运算,a[x][i]为到x为止第i位的1个数前缀和 //对于与运算,如果当前i的前缀和不为 r-l+1 ,则这一位的与运算结果为0 //当找到从左往右第一个位置i为1 ......
Codeforces Round 900 Div Iva

Codeforces Round 901 (Div. 2) C. Jellyfish and Green Apple (位运算)

Codeforces Round 901 (Div. 2) C. Jellyfish and Green Apple //思路:浮点数转二进制,a/b的结果为 gcd(a,b)*最简分式(n/m)的结果 //苹果能分的前提是人数得是一个2的次幂数,通过切割只能分为形同0.001的二进制小数 //a/ ......
Codeforces Jellyfish Apple Round Green

Codeforces Global Round 3

C题就是考虑利用1,n两个端点就好,有些细节要特判。 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #define A puts("Yes") #define B puts ......
Codeforces Global Round

Codeforces Global Round 2

C题结论就是每行每列不同的个数必须是偶数。 D题首先注意到对于长度相同的询问,答案都是一样的。 同时相同的s可以直接丢掉。 那么我们将s排序之后,将相邻的差再进行排序,然后将询问从小到大处理。 相当于是将这些段拼接在一起。 #include<cstdio> #include<algorithm> # ......
Codeforces Global Round

【计算几何】codeforces上面的一点简简单单的计算几何入门题

开篇碎碎念 我真的好喜欢开篇碎碎念啊(可恶真的是太话痨啦)最近有在cf上面写写题,唔不过还没上百题,过两天就可以写百题纪念啦,也还没上青,陌陌菜菜,陌陌在努力变强捏。 cf1850G The Morning Star tag: 用map进行维护,斜率与坐标的关系 题目链接:G. The Mornin ......
几何 codeforces 面的

「题解」Codeforces Round 883 (Div. 3)

A. Escalator Conversations Problem [题目](Rudolph and Cut the Rope) Sol & Code 绳子长度大于钉子高度的要剪 #include <bits/stdc++.h> typedef long long ll; int min(int ......
题解 Codeforces Round 883 Div

「题解」Codeforces Round 888 (Div. 3)

A. Escalator Conversations Problem 题目 Sol & Code 签到 #include <bits/stdc++.h> typedef long long ll; int min(int a, int b) { return a < b ? a : b; } int ......
题解 Codeforces Round 888 Div

10.5 Codeforces Round 638 (Div. 2)

Codeforces Round 638 (Div. 2) A - Phoenix and Balance 思路:加的数成等比关系,且第n项大于前n-1项的和,那么最大的一项加上最小的几个即可 #include<bits/stdc++.h> using namespace std; #define ......
Codeforces Round 10.5 638 Div

「题解」Codeforces Round 891 (Div. 3)

A. Array Coloring Problem 题目 Sol & Code 只有数列的和为偶数时才符合要求,即有任意个偶数,偶数个奇数。 将这些数分成两部分,发现两部分初始值 \(0\) 为偶数,偶数不会影响奇偶性,故需要偶数个奇数。 #include <bits/stdc++.h> #defi ......
题解 Codeforces Round 891 Div

CodeForces 814E An unavoidable detour for home 题解

更好的阅读体验 题意 题目链接 (洛谷翻译) 给出 \(n\) 个点,和每个点的度 \(d_i\) 让你构造出一张无向图满足以下两条性质: 点 \(1\) 到点 \(i\) 仅有 唯一 一条最短路。 点 \(1\) 到点 \(i\) 的最短路长度大于等于点 \(1\) 到点 \(i-1\) 的最短路 ......
题解 unavoidable CodeForces detour 814E

Codeforces Round 901 (Div. 2) - A B

目录A. Jellyfish and UndertaleB. Jellyfish and Game 题目传送门 A. Jellyfish and Undertale 贪心考虑每次时间减到 1 时能否使用工具加时间,注意总时间上限是 a B. Jellyfish and Game 贪心考虑美每位选手肯 ......
Codeforces Round 901 Div

CodeForces 1864H Asterism Stream

洛谷传送门 CF 传送门 好题。 考虑计算 \(x\) 落在 \([1, n - 1]\) 的概率。设 \(f_i\) 为 \(x\) 经过 \(i\) 的概率,答案即为 \(\sum\limits_{i = 1}^{n - 1} f_i\)。 \(f\) 有一个朴素的递推: \[f_i = \be ......
CodeForces Asterism Stream 1864H 1864

Codeforces Round 888 (Div. 3)DEF

Codeforces Round 888 (Div. 3)DEF D. Prefix Permutation Sums 题意:给你一个长度为 \(n - 1\) 的数组,是否能找出一个长度为 \(n\) 的排列,求出这个排列的前缀和,去掉前缀和数组的任意一个元素之后和原来的数组相等。 例如 \([6 ......
Codeforces Round 888 Div DEF

Educational Codeforces Round 155 (Rated for Div. 2)

\(A. Rigged!\) 直接取第一个人能举起的最大重量看他是否是冠军即可。 void solve(){ int n=read(); int fx=read(),ft=read(); int ans=fx; for(int i=1;i<n;i++){ int x=read(),t=read(); ......
Educational Codeforces Round Rated 155

Codeforces 449E - Jzzhu and Squares

显然任意一个顶点是关键点的正方形都可以用两个量来刻画:以其任意一条边对应的直角边平行于坐标轴的直角三角形的两直角边的长度 \(i,j\)(在下文中记这样的正方形为正方形 \((i,j)\))。对于 \(i+j\) 相同的两种正方形,显然一个 \(n\times m\) 的点阵中这样的两正方形个数是相 ......
Codeforces Squares Jzzhu 449E 449

Codeforces 1874F - Jellyfish and OEIS

考虑对 \(\sum m_i-i+1\) 个不可行的集合进行容斥,即钦定一些区间集,要求它们对应的 \(p_l,p_{l+1},\cdots,p_r\) 必须是 \([l,r]\) 的排列,计算方案数乘以容斥系数之和。 如果容斥的集合中存在相交的区间,那么这个方案数其实不太好计算。不过根据区间的性质 ......
Codeforces Jellyfish 1874F 1874 OEIS

Codeforces Round 898 (Div. 4) A~H

Codeforces Round 898 (Div. 4) A~H A. Short Sort 题意:输出不一样的字符的个数 思路:模拟即可 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typ ......
Codeforces Round 898 Div

Codeforces Round 901 (Div. 2)

Preface 摆烂人闪总出列,开个小号摆烂打Div2,龟速1h写完前四题后发现后面三个题过的人数是1/2/1 遂假装挣扎了下看了下EF题面,发现F很可做就开始推式子,后面一看妈的样例都过不去才发现题目看错了 还好拿的新号打的,遂直接无限活力,启动! 后面看了下F原来比我想的还简单来着,E的做法确实 ......
Codeforces Round 901 Div

Codeforces Round 901 (Div. 2)

目录写在前面ABCDE写在最后 写在前面 比赛地址:https://codeforces.com/contest/1875。 爱丽数码我真的好喜欢你啊为了你我要定制你的帆布包口牙!!!! A 显然只会在剩余时间为 1 时使用工具,模拟即可。 // /* By:Luckyblock */ #inclu ......
Codeforces Round 901 Div

「题解」Codeforces Round 894 (Div. 3)

A. Gift Carpet Problem 题目 Sol & Code 签到题 #include <bits/stdc++.h> #define N 21 typedef long long ll; int min(int a, int b) { return a < b ? a : b; } i ......
题解 Codeforces Round 894 Div

CodeForces-1276#B 题解

正文 这是样例 1 第 1 组数据的图。 让我们观察一下,路径 1->6、1->7、2->6、2->7 是可行的,所以答案为 4。 上述路径中好像点 4 没有贡献? 再看看样例 1 第 2 组数据的图。 发现点 1 和点 4 相互之间存在其他路径,无需经过点 \(a\) 和点 \(b\)。 综上,我 ......
题解 CodeForces 1276

Codeforces Round 730 (Div. 2) B. Customising the Track

有 \(n\) 条高速公路,第 \(i\) 条告诉公路上的车流为 \(a_i\) 。现在可以执行以下操作任意次: 将第 \(i\) 条高速公路上的一辆车移到第 \(j\) 条高速公路。 需要求最小的 \(\sum_{i = 1}^{n}\sum_{j=i+1}^{n} |a_i - a_j|\) 。 ......
Customising Codeforces Round Track 730

Educational Codeforces Round 112 (Rated for Div. 2) A. PizzaForces

有三种披萨:\(6\)、\(8\)、\(10\) 块披萨。制作时间分别需要:\(15\)、\(20\)、\(25\) 分钟。现在有 \(n\) 个人,每人需要一块披萨。询问使所有人能获得披萨的最快时间。 观察:发现三种披萨的性价比都一样。(否则按最优性价比贪心) 需要让得到的披萨数量 \(m \ge ......

题解 Codeforces Round 901 (Div. 1) / CF1874A~E

题解 Codeforces Round 901 (Div. 1) / CF1874A~E 比赛情况:过了 AB。赛后发现 B 是假复杂度。 https://codeforc.es/contest/1874 A. Jellyfish and Game Problem Alice & Bob 又在博弈, ......
题解 Codeforces Round 1874 901