题意: 给你一个n的数组,你可以进行无数次,选择区间使得区间内的值相加,然后区间的所有的值变成平均值. 使得最后数组的字典序最小 思路: 最后的数组一定是单调递增的,只要它比之前的平均值数大,就不会操作,如果比他小,需要进行操作到符合它的范围 用单调递减栈进行操作 #include<bits/stdc++.h> using namespace std; #define ll long long #define il inline #define it register int #define…
Guy-Manuel and Thomas have an array aa of nn integers [a1,a2,…,an ]. In one step they can add 11 to any element of the array. Formally, in one step they can choose any integer index ii (1≤i≤n ) and do ai:=ai+1 . If either the sum or the product of al…
Anu has created her own function ff : f(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9. It can be proved that for any nonnegative numbers xx and yy value of f(x,y)f(x,y) is also nonnegative. She would lik…
这一场涨了不少,题也比较偏思维,正好适合我 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…
Reminder: the median of the array [a1,a2,-,a2k+1] of odd number of elements is defined as follows: let [b1,b2,-,b2k+1] be the elements of the array in the sorted order. Then median of this array is equal to bk+1. There are 2n students, the i-th stude…