fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define int long long
  7. #define pb push_back
  8. #define all(x) (x).begin(),(x).end()
  9. #define fi first
  10. #define se second
  11.  
  12. int const MAXN=1e5+10;
  13. int const INF=1e18;
  14.  
  15. void open(){
  16. ios_base::sync_with_stdio(false);
  17. cin.tie(NULL); cout.tie(NULL);
  18. // freopen(TASK".INP","r",stdin);
  19. // freopen(TASK".OUT","w",stdout);
  20. }
  21.  
  22. bool compareVal(string a,string b){
  23. return a+b>b+a;
  24. }
  25.  
  26. int n;
  27. string a[MAXN];
  28.  
  29. signed main(){
  30. open();
  31. cin>>n;
  32.  
  33. for(int i=1;i<=n;i++){
  34. cin>>a[i];
  35. }
  36. sort(a+1,a+n+1,compareVal);
  37.  
  38. for(int i=1;i<=n;i++){
  39. cout<<a[i];
  40. }
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 6720KB
stdin
Standard input is empty
stdout
Standard output is empty