← Back to List

10973번: 이전 순열 ↗

Solutions

C++14
234 B | 234 chars
#include <iostream>
#include <algorithm>
using namespace std;
int N,ar[11000];
int main()
{
	cin>>N;
	for(int x=0; x<N; x++)cin>>ar[x];
	if(prev_permutation(ar,ar+N))
	{
		for(int x=0; x<N; x++)cout<<ar[x]<<" ";
	}
	else cout<<"-1";
}