CF1300E Water Balance】的更多相关文章

题目链接 problem 给出一个长度为n的序列,每次可以选择一个区间\([l,r]\)并将区间\([l,r]\)内的数字全部变为这些数字的平均数.该操作可以进行任意多次. 求出进行任意次操作后可以得到的字典序最小的序列. solution 可以证明不存在一个数字被进行两次或以上运算.即不存在如下情况: 显然\([2,3]\)处的平均值小于\([1,2]\)处的平均值(否则红色线不会包含2,3).4处的值大于\([1,3]\)的平均值(否则红色线会包含4).然后蓝色线进行选择的时候,因为\([1…
给你n个数,你可以这样操作:使区间[l,r]的数变成 他们的平均数,求字典序最小的序列. 做法:从左往右逐个比较,比较完之后会形成一个区间,一开始是区间为1的数进行比较,到后来会 变成区间较大的进行比较: 举个例子:7 6 5 4 3 2 3 显而易见,递减序列肯定是要求平均值的,但是求出来之后,会得出一个值,这个值有可能大于或小于等于右边的数 这就需要再次进行比较,所以每次比较都是以区间的形式: 代码中区间为block #include<bits/stdc++.h> #define IOS…
给你一个数列,有一个操作,将一段数字变成其和除以个数,求字典序最小的那一个,分析知,求字典序最小,就是求一个不下降序列,但我们此时有可以更改数字的操作,已知已经不下降的序列不会因为操作而变的更小,只有右边的数比左边的数小的时候才需要操作,那我们可以维护一个单调栈,依次加入数字,栈顶就是当前最右的数字,再维护一个长度信息,这样,每次加入一个数就能判断是否需要操作了,若需要操作,就更新长度和数字进行即可 #include<bits/stdc++.h> using namespace std; #d…
题库链接 https://codeforces.ml/contest/1300 A. Non-zero 一个数组,每次操作可以给某个数加1,让这个数组的积和和不为0的最小操作数 显然如果有0的话,必须操作一次,最后如果和还是为0的话,再操作一次 #include <bits/stdc++.h> using namespace std; #define mem(a,b) memset(a,b,sizeof(a)) #define pii pair<int,int> #define i…
这一场涨了不少,题也比较偏思维,正好适合我 A. Non-zero 我们记录这些数字的总和sum,并且记录0的个数zero,显然答案应该是这些0的个数,注意如果sum+zero==0的话答案要额外加一(因为总和不能是0) #include<bits/stdc++.h> #define LL long long #define maxn 100010 #define x first #define y second using namespace std; typedef pair<int…
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…
记录 Codeforces 2019年12月19日到 2020年2月12日 的部分比赛题 Educational Codeforces Round 82 (Rated for Div. 2) D Fill The Bag 给出m(≤1e5)个盒子,盒子的大小是2的幂次.可以选择把一个盒子分成大小相同的两部分,问最少执行几次分盒子的操作,可以装满大小为n(≤1e18)的背包. 把n转化为二进制,代表可以由若干种2的幂次的盒子各一个装满.从小往大贪心地使用已有的盒子,不足时把第一个比它大的盒子分开.…
2021-10-14 P2577 [ZJOI2004]午餐 2021-10-13 CF815C Karen and Supermarket(小小紫题,可笑可笑) P6748 『MdOI R3』Fallen Lord(sort(a+1,a+1+n,greater<int>()); 真好用) P4161 [SCOI2009]游戏 P1707 刷题比赛 2021-10-12 CF1573A Countdown P2717 寒假作业 P7868 [COCI2015-2016#2] VUDU P1660…
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" touches the right and bottom edges. Wate…
Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining. Note: Both m and n are less than 110. The height of each unit cell is greater th…