CF645B.Mischievous Mess Makers
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bessie's limelight, has formed the Mischievous Mess Makers and is plotting to disrupt this beautiful pastoral rhythm. While Farmer John takes his k minute long nap, Elsie and the Mess Makers plan to repeatedly choose two distinct stalls and swap the cows occupying those stalls, making no more than one swap each minute.
Being the meticulous pranksters that they are, the Mischievous Mess Makers would like to know the maximum messiness attainable in the k minutes that they have. We denote as p__i the label of the cow in the i-th stall. The messiness of an arrangement of cows is defined as the number of pairs (i, j) such that i < j and p__i > p__j.
这是一个温暖宜人的春日下午,农夫约翰的 n 头奶牛正各自在牛栏中反刍,思考着“链剖仙人掌”(link-cut cacti)的问题。这些奶牛编号为 1 到 n,并按顺序排列,使得第 i 头奶牛恰好位于从左往右数的第 i 个牛栏中。然而,埃尔西在意识到自己将永远活在贝茜(Bessie)的光环阴影之下后,组建了“恶作剧制造者”(Mischievous Mess Makers),并密谋扰乱这和谐优美的田园节奏。在农夫约翰小憩 k 分钟期间,埃尔西与“恶作剧制造者”计划反复选择两个不同的牛栏,并交换其中奶牛的位置;每分钟至多执行一次交换。
作为一丝不苟的恶作剧高手,“恶作剧制造者”希望知道自己在 k 分钟内所能达到的最大混乱度(messiness)。我们记 pi 为第 i 个牛栏中奶牛的编号。一个奶牛排列的混乱度定义为满足 i<j 且 pi>pj 的数对 (i,j) 的个数。
输入格式
The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100 000) — the number of cows and the length of Farmer John's nap, respectively.
输入的第一行包含两个整数 n 和 k(1 ≤ n, k ≤ 100000),分别表示奶牛的数量和农夫约翰小睡的时长。
输出格式
Output a single integer, the maximum messiness that the Mischievous Mess Makers can achieve by performing no more than k swaps.
输出一个整数,表示“恶作剧制造者”在最多执行 k 次交换的情况下所能达到的最大混乱度。
输入输出样例
输入#1
5 2
输出#1
10
输入#2
1 10
输出#2
0
说明/提示
In the first sample, the Mischievous Mess Makers can swap the cows in the stalls 1 and 5 during the first minute, then the cows in stalls 2 and 4 during the second minute. This reverses the arrangement of cows, giving us a total messiness of 10.
In the second sample, there is only one cow, so the maximum possible messiness is 0.
在第一个样例中,捣蛋的混乱制造者可以在第一分钟交换第 1 和第 5 号牛栏中的奶牛,然后在第二分钟交换第 2 和第 4 号牛栏中的奶牛。这将奶牛的排列完全反转,从而得到总混乱度为 10。
在第二个样例中,仅有一头奶牛,因此可能的最大混乱度为 0。
输入解题思路,AI测评打分。不知道怎么写?