96032024-02-23 14:12:35csaron71Kombináció (50)cpp17Partially correct 44/503ms3692 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> szamok(m);
	for (int i=0; i<m; i++) {
		cin >> szamok[i];
	}

	//nagyobb
	bool legnagyobb=true; //legnagyobb e?
	bool legkisebb=true;
	for (int i=0; i<m; i++) {
		if (szamok[m-i-1]!=n-i) {
			//cout << "nemnagy\n";
			legnagyobb=false;
		}
		if (szamok[i]!=i+1) {
			//cout << "Nemkicsi\n";
			legkisebb=false;
		}
	}
	if (legnagyobb==true) {
		//legnagyobb
		cout << szamok[0]-1 << " ";
		for (int i=1; i<m; i++) {
			cout << szamok[i] << " ";
		}
		cout << "\n";
		for (int i=0; i<m; i++) {
			cout << i+1 << " ";
		}
		return 0;
	}/*
	if (legkisebb==true) {
		for (int i=n-m+1; i<n+1; i++) {
			cout << i << " ";
		}
		cout << "\n";
		for (int i=0; i<m-1; i++) {
			cout << i+1 << " ";
		}
		cout << m+1 << " \n";
		return 0;
	}*/

	//kisebb
	int kindex=0;
	int kicsi=-1;
	for (int i=1; i<m; i++) {
		if (szamok[m-i]-szamok[m-i-1]!=1) {
			//cout << i << "\n";
			kindex=m-i;
			kicsi=szamok[m-i]-1;
			break;
		}
	}
	if (kicsi==-1) {
		cout << szamok[0]-1 << " ";
		for (int i=1; i<m; i++) {
			cout << i+n-m+1 << " ";
		}
	}
	else {
		for (int i=0; i<kindex; i++) {
			cout << szamok[i] << " ";
		}
		cout << kicsi << " ";
		for (int i=n-(m-kindex-1)+1; i<=n; i++) {
			cout << i << " ";
		}
	}

	cout << "\n";

	//nagyobb
	int hanyadik=-1;
	int melyik=-1;
	for (int i=0; i<m; i++) {
		if (szamok[m-i-1]!=n-i) {
			//cout << m-i << "\n\n";
			hanyadik=m-i-1;
			melyik=szamok[m-i-1]+1;
			break;
		}
	}
	for (int i=0; i<hanyadik; i++) {
		cout << szamok[i] << " ";
	}
	for (int i=0; i<m-hanyadik; i++) {
		cout << melyik+i << " ";
	}


}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2000 KiB
3Partially correct1/23ms2252 KiB
4Accepted2/23ms2428 KiB
5Partially correct1/23ms2640 KiB
6Accepted2/23ms2724 KiB
7Accepted2/23ms2988 KiB
8Partially correct1/23ms2856 KiB
9Partially correct1/23ms3008 KiB
10Accepted4/43ms3024 KiB
11Accepted4/43ms3216 KiB
12Accepted4/43ms3228 KiB
13Accepted4/43ms3232 KiB
14Partially correct2/43ms3236 KiB
15Accepted4/43ms3360 KiB
16Accepted6/63ms3568 KiB
17Accepted6/63ms3692 KiB