1038. Recover the Smallest Number (30)
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class CA
{
public:
void run();
string allnum;
vector<string> sl;
};
bool abcmp(const string &a,const string &b)
{
return a+b<b+a;
}
void CA::run()
{
int n,i;
string s;
cin>>n;
while(n-->0)
{
cin>>s;
sl.push_back(s);
}
sort(sl.begin(),sl.end(),abcmp);
for(i=0;i<sl.size();i++)
{
allnum+=sl[i];
}
for(i=0;i<allnum.size();i++)
{
if(allnum[i]!='0') break;
}
allnum=allnum.substr(i,allnum.size()-i);
if(allnum.size()>0) cout<<allnum<<endl;
else cout<<0<<endl;
}
int main()
{
// freopen("test.in","r",stdin);
CA *a=new CA;
a->run();
return 0;
}