CF424A.Squats
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.
For another exercise, Pasha needs exactly
hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster ether sit down or stand up. How many minutes will he need to get what he wants if he acts optimally well?
帕沙养了很多仓鼠,他让这些仓鼠进行锻炼。今天,共有 n 只仓鼠(n 为偶数)来锻炼。这些仓鼠排成一列,每只仓鼠要么坐着,要么站着。
在另一项训练中,帕沙需要恰好
只仓鼠站立,其余仓鼠坐下。帕沙每分钟可以令某只仓鼠由坐变站,或由站变坐。如果他采取最优策略,最少需要多少分钟才能达到目标?
输入格式
The first line contains integer n (2 ≤ n ≤ 200; n is even). The next line contains n characters without spaces. These characters describe the hamsters' position: the i-th character equals 'X', if the i-th hamster in the row is standing, and 'x', if he is sitting.
第一行包含一个整数 n(2≤n≤200;n 为偶数)。
第二行包含 n 个无空格的字符。这些字符描述仓鼠的姿势:若第 i 只仓鼠站立,则第 i 个字符为 'X';若其坐下,则为 'x'。
输出格式
In the first line, print a single integer — the minimum required number of minutes. In the second line, print a string that describes the hamsters' position after Pasha makes the required changes. If there are multiple optimal positions, print any of them.
第一行输出一个整数——所需的最少分钟数。
第二行输出一个字符串,描述帕沙完成必要调整后仓鼠的位置。如果存在多个最优位置,输出其中任意一个即可。
输入输出样例
输入#1
4 xxXx
输出#1
1 XxXx
输入#2
2 XX
输出#2
1 xX
输入#3
6 xXXxXx
输出#3
0 xXXxXx
输入解题思路,AI测评打分。不知道怎么写?