http://codeforces.com/contest/1038

A

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define IT set<node>::iterator
 6 #define sqr(x) ((x)*(x))
 7 #define pb push_back
 8 #define eb emplace_back
 9 #define maxn 100005
10 #define eps 1e-8
11 #define pi acos(-1.0)
12 #define rep(k,i,j) for(int k=i;k<j;k++)
13 typedef long long ll;
14 typedef pair<int,int> pii;
15 typedef pair<ll,ll>pll;
16 typedef pair<ll,int> pli;
17 typedef pair<pair<int,string>,pii> ppp;
18 typedef unsigned long long ull;
19 const long long MOD=1e9+7;
20 const double oula=0.57721566490153286060651209;
21 using namespace std;
22 
23 int a[27];
24 
25 int main(){
26     std::ios::sync_with_stdio(false);
27     int n,m;
28     string str;
29     cin>>n>>m>>str;
30 
31     for(int i=0;i<n;i++){
32         a[str[i]-'A']++;
33     }
34     sort(a,a+26);
35     int ans=0x3f3f3f3f;
36     int co=0;
37     for(int i=25;i>=0;i--){
38 
39         if(a[i]==0) break;
40         ans=min(ans,a[i]);
41         co++;
42     }
43     if(co<m) cout<<0;
44     else cout<<ans*co;
45 }
View Code

相关文章:

  • 2021-08-12
  • 2021-04-24
  • 2021-12-04
  • 2021-11-19
  • 2021-04-27
  • 2021-08-14
  • 2021-08-20
猜你喜欢
  • 2021-10-01
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案