0
已解决
高子骞
高级守护
高级守护
题目链接: 酷町堂:4864
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
string a[100005];
int s;
bool cmp(string x,string y){
int cx,cy;
string tx,ty;
for(int i=0;i<x.size();i++){
if(x[i]>='0'&&x[i]<='9'){
cx+=x[i]-'0';
tx+=x[i];
}
}
for(int i=0;i<y.size();i++){
if(y[i]>='0'&&y[i]<='9'){
cy+=y[i]-'0';
ty+=y[i];
}
}
if(cx!=cy){
return cx > cy;
}else if(tx!=ty){
return tx < ty;
}
return x < y;
}
int main(){
cin>>s;
getline(cin,a[0]);
for(int i=1;i<=s;i++){
getline(cin,a[i]);
}
sort(a+1,a+s+1,cmp);
for(int i=1;i<=s;i++){
cout<<a[i]<<endl;
}
return 0;
}