T744540 题解(还没写好)
AwA
这道题我们先要得到字符串
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int r[26]={0};
int n,x,y,j,z;
cin>>n;
cin>>s;
for(int i=0;i<n;i++)r[s[i]-97]++;
for(int i=0;i<n;i++){
y=s[i]-97;
x=0;
for(j=25;j>y;j--)if(r[j]>0)x++;
z=0;
for(j=0;j<26;j++){
if(r[j]>0){
if(x==0){
z=j;
break;
}
x--;
}
}
cout<<char(z+97);
}
}