image.png
/*
Sample Input:
5 32 321 3214 0229 87
Sample Output:
22932132143287
*/
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
bool cmp_segment(string a, string b) {
return a + b < b + a;
}
string str[100010], ans;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++)
cin >> str[i];
sort(str, str + N, cmp_segment);
for (int i = 0; i < N; i++)
ans += str[i];
while (ans.length() != 0 && ans[0] == '0')
ans.erase(ans.begin());
if (ans.length() == 0)
cout << 0;
else
cout << ans;
return 0;
}
网友评论