思路:
首先排序(经验之谈)
分类讨论
我们要做到不重不漏的分类
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6 + 10;
char dist[N];
int n, x;
int main()
{
string str;
cin >> n >> x >> dist + 1;
sort (dist + 1, dist + n + 1);
dist[0] = dist[1];//当x = 1时也符合第二种情况
if (dist[1] == dist[n])
for (int i = 1; i <= n / x + (n % x ? 1 : 0); i++)
cout << dist[i];
else if (dist[x] == dist[1])
for (int i = x; i <= n; i++)
cout << dist[i];
else
cout << dist[x];
return 0;
}