Precreation contest files
This commit is contained in:
31
misc/chuyen-de-xau/b4.cpp
Normal file
31
misc/chuyen-de-xau/b4.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
string S[100];
|
||||
|
||||
bool check(const string &a, const string &b) {
|
||||
const string ab = a + b, ba = b + a;
|
||||
if (stoi(ab) < stoi(ba))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(NULL);
|
||||
freopen("B4.INP", "r", stdin);
|
||||
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 0; i < n; i++) {
|
||||
string a;
|
||||
cin >> a;
|
||||
S[i] = a;
|
||||
}
|
||||
|
||||
sort(S, S + n, check);
|
||||
for (int i = 0; i < n; i++) {
|
||||
cout << S[i];
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
Reference in New Issue
Block a user