#include<bits/stdc++.h> using namespace std; int n,a[10000]; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; if(prev_permutation(a,a+n)) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl; return 0; }
By signing up a HFOJ universal account, you can submit code and join discussions in all online judging services provided by us.
Using your HFOJ universal account