32 lines
509 B
C++
32 lines
509 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
string S[100];
|
|
|
|
bool check(const string &a, const string &b) {
|
|
const string ab = a + b, ba = b + a;
|
|
if (stoi(ab) < stoi(ba))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
int main() {
|
|
ios_base::sync_with_stdio(false);
|
|
cin.tie(NULL);
|
|
freopen("B4.INP", "r", stdin);
|
|
|
|
int n;
|
|
cin >> n;
|
|
for (int i = 0; i < n; i++) {
|
|
string a;
|
|
cin >> a;
|
|
S[i] = a;
|
|
}
|
|
|
|
sort(S, S + n, check);
|
|
for (int i = 0; i < n; i++) {
|
|
cout << S[i];
|
|
}
|
|
cout << '\n';
|
|
}
|