1038. Recover the Smallest Number

 #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef const string & csr;
int main(){
  vector<string>vs;
  int n,i;
  cin>>n;
  while(n--){ string s; cin>>s; vs.push_back(s); }
  sort(vs.begin(),vs.end(),[](csr a,csr b){return a+b<b+a;});
  for(i=0;i<vs.size()&&!stoi(vs[i]);++i);
  cout<<(i<vs.size()?stoi(vs[i++]):0);
  while(i<vs.size())cout<<vs[i++];
}

你可能感兴趣的:(1038. Recover the Smallest Number)