You are given an array consisting of nn integers a1,a2,…,ana1,a2,…,an , and a positive integer mm . It is guaranteed that mm is a divisor of nn . In a single move, you can choose any position ii between 11 and nn and increase aiai by 11 . Let's calcu…
D. Equalize Them All time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. You can perform the following operations arbitrary number of times…
D. Equalize Them All time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array aa consisting of nn integers. You can perform the following operations arbitrary number of times…
链接: https://codeforces.com/contest/1234/problem/A 题意: You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs ai coins. You got tired of remembering the price of each product when customers ask fo…
题意:有一组数,可以选择某个数\(a_i\)相邻的一个数\(a_j\),然后可以让\(a_i\)加上或者减去\(|a_i-a_j|\),问最少操作多少次使得数组中所有数相同. 题解:不难发现,每次操作必然可以使得一个数等于它旁边的任意一个数,所以让数组中的其他数等于出现次数最多的那个数一定是最优的,然后我们就去找与那个数相邻的数去求块,正着反着模拟输出一下就可以了,具体看代码吧. 代码: int n; int a[N]; map<int,int> mp; int mx,res; bool st…
http://codeforces.com/contest/1144 A. Diverse Strings A string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: "fced", &qu…