当前位置: 首页 > news >正文

网站建设开发设计营销公司山东百度本地惠生活推广

网站建设开发设计营销公司山东,百度本地惠生活推广,网站制作公司 沈阳,WordPress网站注册账户原题链接 纯纯水一下; 昨天晚上的比赛,由于半夜打的,精神状态不好,wa了俩发直接睡觉去了,现在白天写写发现,不难,水中水 模拟题吧,题目怎么说就这么作 Kristina has a string ss…

原题链接

纯纯水一下;

昨天晚上的比赛,由于半夜打的,精神状态不好,wa了俩发直接睡觉去了,现在白天写写发现,不难,水中水

模拟题吧,题目怎么说就这么作

Kristina has a string ss of length nn, consisting only of lowercase and uppercase Latin letters. For each pair of lowercase letter and its matching uppercase letter, Kristina can get 11 burl. However, pairs of characters cannot overlap, so each character can only be in one pair.

For example, if she has the string ss = "aAaaBACacbE", she can get a burl for the following character pairs:

  • s1s1 = "a" and s2s2 = "A"
  • s4s4 = "a" and s6s6 = "A"
  • s5s5 = "B" and s10s10 = "b"
  • s7s7= "C" and s9s9 = "c"

Kristina wants to get more burles for her string, so she is going to perform no more than kk operations on it. In one operation, she can:

  • either select the lowercase character sisi (1≤i≤n1≤i≤n) and make it uppercase.
  • or select uppercase character sisi (1≤i≤n1≤i≤n) and make it lowercase.

For example, when kk = 2 and ss = "aAaaBACacbE" it can perform one operation: choose s3s3 = "a" and make it uppercase. Then she will get another pair of s3s3 = "A" and s8s8 = "a"

Find maximum number of burles Kristina can get for her string.

Input

The first line of input data contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases.

The description of the test cases follows.

The first line of each test case contains two integers nn (1≤n≤2⋅1051≤n≤2⋅105) and kk (0≤k≤n0≤k≤n) — the number of characters in the string and the maximum number of operations that can be performed on it.

The second line of each test case contains a string ss of length nn, consisting only of lowercase and uppercase Latin letters.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052⋅105.

Output

For each test case, print exactly one integer on a separate line: the maximum number of burles that Kristina can get for her string ss.

Example

input

Copy

 

5

11 2

aAaaBACacbE

2 2

ab

4 1

aaBB

6 0

abBAcC

5 3

cbccb

output

Copy

5
0
1
3
2

Note

The first test case is explained in the problem statement.

In the second test case, it is not possible to get any pair by performing any number of operations.

#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<stack>
#include<string>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<cstring>
#include<queue>
#include<set>
#include<stdlib.h>
#define dbug cout<<"hear!"<<endl;
#define rep(a,b) for(int i=a;i<=b;i++)
#define rrep(a,b) for(int j=a;j<=b;j++)
#define per(a,b) for(int i=a;i>=b;i--)
#define pper(a,b) for(int j=a;j>=b;j--)
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 100;
const int  INF = 0x3f3f3f3f;
ll gcdd(ll a, ll b)
{if (b) while ((a %= b) && (b %= a));return a + b;
}
const int mod = 998244353;
ll t, n,m,a,b, c, x, k, cnt,ans, ant, sum, q, p, idx;
ll arr[N], brr[N], crr[N];int main()
{cin >> t;while (t--){cin >> n >> m;string s;cin >> s;map<int, int>mp;rep(0, n - 1){mp[s[i]]++;}ans = 0;for (int i = 'A';i <= 'Z';i++){while (mp[i] && mp[i + 32]){ans++;mp[i]--;mp[i + 32]--;}}for (int i = 'A';i <= 'Z';i++){while (m > 0 && mp[i] - 2 >= 0){ans++;mp[i] -= 2;m--;}}for (int i = 'a';i <= 'z';i++){while (m > 0 && mp[i] - 2 >= 0){ans++;mp[i] -= 2;m--;}}cout << ans<<endl;}
}

 

http://www.dinnco.com/news/30421.html

相关文章:

  • 太原网站制作报价seo实战培训教程
  • 什么是一学一做视频网站中国十大企业培训机构排名
  • 网站版面风格茶叶网络推广方案
  • 湛江做寄生虫网站seddog站长之家
  • 测试网站小程序怎么做品牌网站建设制作
  • 电商管理系统百度怎么优化排名
  • 企业网站做速优化排名万象网页开发工具
  • 筑招建筑人才网长春安全员seo关键字优化技巧
  • 镇江哪里做网站小升初最好的补课机构排行榜
  • 做外贸比较好得网站外国网站开放的浏览器
  • 找人做网站都需要提供什么seo查询平台
  • 专业做网站排名的人企业网站推广的形式有哪些
  • wordpress 手机支付乐天seo培训
  • 国内优秀网页设计案例天津百度seo
  • 青岛君哲网站建设公司重庆seo技术博客
  • 哪个网站可以付费做淘宝推广百度空间登录入口
  • 备案网站负责人网站自助建站系统
  • 乐基儿做黎明网站的女郎今日新闻最新事件
  • 赤峰市哪里做网站网络推广主要是做什么工作
  • 深圳外贸建站与推广西安优化排名推广
  • 镇海官方网站建设网页设计作品集
  • 本地环说wordpress配置邮箱seo一个月赚多少钱
  • 宝安区哪一个街道最富裕seo云优化如何
  • wordpress 好 免费主题无锡网站优化
  • 做面包有关电影网站网站外链工具
  • 金坛常州做网站营销网址
  • 自己做网站开微店可行吗宁德市教育局官网
  • 黑龙江俄语网站制作小程序排名优化
  • logo设计网站国外外贸网站建设报价
  • 有专业做网站的学校吗网站推广技巧有哪些