fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool cmp(const string& a, const string &b){
  5. return a+b>b+a;
  6. }
  7. int main(){
  8. if(fopen("BAI2.INP","r")){
  9. freopen("BAI2.INP","r",stdin);
  10. freopen("BAI2.OUT","w",stdout);
  11. }
  12. int n;
  13. cin >> n;
  14. vector<string> a(n);
  15. for(int i = 0;i < n;i++){
  16. cin >> a[i];
  17. }
  18. string res = "";
  19. sort(a.begin(),a.end(),cmp);
  20.  
  21. for(const string& num : a){
  22. res += num;
  23. }
  24. cout << res;
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty