Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake…
D. Berland Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output XXI Berland Annual Fair is coming really soon! Traditionally fair consists of nn booths, arranged in a circle. The booths ar…
Three Equal Time limit: 1000 msMemory limit: 256 MB You are given an array AA of NN integers between 00 and 22. With cost 11 you can apply the following operation A_i = ((A_i + 1)\ \% \ 3)Ai=((Ai+1) % 3). Find the minimum cost to make all ele…
csa66 Risk Rolls Time limit: 1000 msMemory limit: 256 MB Alena and Boris are playing Risk today. We'll call an outcome the sum of values on the faces of 111 or more rolled dice. Alena has NNN possible outcomes whilst Boris has MMM. In turns, each o…
传送门 题意 给出一个排列,定义\(value为\sum_{i=1}^{n-1}abs(f[i+1]-f[i])\) \(swap(a[i],a[j])(i≠j)为一次交换\),询问最少的交换次数使得value最大 分析 如果f[i+1]>f[i],答案就+f[i+1]-f[i]; 如果f[i+1]<f[i],答案就+f[i]-f[i+1]; 那么我们可以找到一个pretty good solution 定义 L 为 f[i]<=n/2, R 为 f[i]>n/2, 得到L R L…