Created
October 21, 2019 13:29
-
-
Save surinoel/768a01c120b0b8205f269c458d28d612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int arr[1000]; | |
bool cmp(const int &u, const int &v) { | |
string a = to_string(u) + to_string(v); | |
string b = to_string(v) + to_string(u); | |
return a > b; | |
} | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int n; | |
cin >> n; | |
for (int i = 0; i < n; i++) { | |
cin >> arr[i]; | |
} | |
sort(arr, arr + n, cmp); | |
string ans = ""; | |
for (int i = 0; i < n; i++) { | |
ans += to_string(arr[i]); | |
} | |
if (ans.length() > 1 && ans[0] == '0') { | |
ans = "0"; | |
} | |
cout << ans << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment