7.11 cf div3 A

Problem - A - Codeforces

题目概述

求最少问题数量,以确保能举办m轮比赛,每轮包含一个难度级别为 ‘A’ 到 ‘G’ 的问题。

ac代码
#include<bits/stdc++.h>
typedef long long ll;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const ll N=1e3;
using namespace std;

int main()
{
    IOS;
    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        string a;
        cin>>a;
        map<int,char>mp;
        for(int i=0;i<n;i++)
        {
            mp[a[i]]++;
        }
        int ans=0;
        for(char k='A';k<='G';k++)
        {
            if(mp[k]<m) ans+=m-mp[k];
        }
        cout<<ans;
        cout<<endl;
    }
    return 0;
}

相关推荐

  1. WorldModels-A3C

    2024-07-11 12:40:04       44 阅读
  2. Codeforces Round 913 (Div. 3) (A-G)

    2024-07-11 12:40:04       43 阅读
  3. Codeforces Round 916 (Div. 3)(A~F)

    2024-07-11 12:40:04       62 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 12:40:04       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 12:40:04       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 12:40:04       57 阅读
  4. Python语言-面向对象

    2024-07-11 12:40:04       68 阅读

热门阅读

  1. Spring AOP 基础知识

    2024-07-11 12:40:04       23 阅读
  2. PHP MySQL 简介

    2024-07-11 12:40:04       23 阅读
  3. linux 文件末尾追加内容

    2024-07-11 12:40:04       22 阅读
  4. 从IE到Edge:微软浏览器的演变与未来展望

    2024-07-11 12:40:04       23 阅读
  5. 浅谈ES6

    2024-07-11 12:40:04       21 阅读
  6. 风景园林工程设计乙级资质业绩要求案例分析

    2024-07-11 12:40:04       23 阅读
  7. 高效利用iCloud:全面指南与技术深度解析

    2024-07-11 12:40:04       25 阅读
  8. Linux 宝塔常用命令教程

    2024-07-11 12:40:04       21 阅读
  9. HDFS体系架构&文件写入/下载流程

    2024-07-11 12:40:04       24 阅读