Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define ALL(x) x.begin(),x.end()
- #define SZ(x) x.size()
- #define PB push_back
- #define MP make_pair
- #define F first
- #define S second
- typedef long long LL;
- typedef vector<int> VI;
- typedef pair<int,int> PI;
- string a,b;
- int ans;
- int main() {
- io
- cin >> a >> b;
- sort(ALL(a));
- int x = stoi(b);
- int y = stoi(a);
- if(y > x || SZ(a) > SZ(b))
- return 0*puts("-1");
- do {
- y = stoi(a);
- if(y <= x)
- ans = max(ans,y);
- } while(next_permutation(ALL(a)));
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement