Berry Jam (前缀和)cf教育场】的更多相关文章

距离上一篇博客又2个月了 寻思着该除除草了 教育场是真的好难 可能是因为我还是只菜鸡 哭唧唧 先说下题意:有2*n罐果酱,草莓和蓝莓,梯子在中间从梯子那开始往两边吃(可以一会左一会右),问最少吃多少果酱可以使两种酱剩下的数量相等. 一开始没写出来,看了大佬的做法才会的.(因为下午刚考完拉链法冲突处理脑海里都是他ing,然后发现想复杂了.....) 题解:先将为2的改成-1.梯子右边从最右边开始求前缀和(前边所有果酱中两种果酱的差),记录前缀和的下标在数组c中(这个地方可能会有前缀和是一样的,那当…
Educational Codeforces Round 78 (Rated for Div. 2) C - Berry Jam C. Berry Jam time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Karlsson has recently discovered a huge stock of berry jam jar…
链接: https://codeforces.com/contest/1278/problem/C 题意: Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were 2n jars of strawberry and blueberry jam. All the 2n jars are arranged in…
Forewords 说实话我是被图吸引进来的23333,图画的真的挺好看. 题意 你从一个梯子下到地下室,梯子左右两边各有 \(n\) 瓶果酱排成一排,果酱口味为草莓味或蓝莓味,你每次只能吃你左边或右边没吃过的那瓶,求最少要吃多少瓶才能使两种口味的果酱数量相等. 题解 以样例为例,有 \(7\) 罐草莓味的和 \(5\) 罐蓝莓味的. 然后一直往右边吃,吃到这个时候,吃掉了 \(3\) 草蓝莓味的和 \(2\) 罐蓝莓味的,剩下 \(r_\text{left}=4\) 罐草莓味的和 \(b_\t…
A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegm…
A. Array with Odd Sum Description You are given an array \(a\) consisting of \(n\) integers. In one move, you can choose two indices \(1 \le i, j \le n\) such that \(i \ne j\) and set \(a_i := a_j\). You can perform such moves any number of times (po…
A. Non-zero Description: Guy-Manuel and Thomas have an array \(a\) of \(n\) integers [\(a_1, a_2, \dots, a_n\)]. In one step they can add \(1\) to any element of the array. Formally, in one step they can choose any integer index \(i\) (\(1 \le i \le…
题目大意: 有两种类型的果酱,一个梯子,从中间开始吃,可以吃左边的,也可以吃右边的,最终要使两种类型的果酱的数量想等 题解: 思路对了,但是没考虑完. 对梯子的左侧的果酱I我们用两个数组记录其从1到i的1的数量和从1到i的2的数目,对梯子右侧的果酱保存从i到n的1的数目和2的数目. 然后两种情况, 第一种是最终答案最侧与右侧均有果酱剩余.我们只需要让左侧的1-2等于右侧2-1. 第二种情况,最终答案出现在一侧, 即左侧都吃光或者右侧都吃光. #include<bits/stdc++.h> us…
比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B:数学+排序 C:字符串搜索 A // https://codeforces.com/contest/1277/problem/A /* 题意: 给出一个数,求不大于该数的完美整数的个数(完美整数指全是一个数组成的数字,如:111, 333333, 444444, 9, 8888 ...) 分析:…