95992024-02-23 14:09:30csaron71Kombináció (50)cpp17Partially correct 43/503ms3652 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
base43/50
1Accepted0/03ms1816 KiB
2Accepted0/03ms2052 KiB
3Partially correct1/23ms2216 KiB
4Partially correct1/23ms2472 KiB
5Accepted2/23ms2708 KiB
6Accepted2/23ms2916 KiB
7Accepted2/22ms2964 KiB
8Partially correct1/23ms3092 KiB
9Accepted2/23ms3304 KiB
10Accepted4/42ms3424 KiB
11Accepted4/42ms3520 KiB
12Accepted4/42ms3508 KiB
13Partially correct2/42ms3520 KiB
14Partially correct2/43ms3412 KiB
15Accepted4/42ms3532 KiB
16Accepted6/62ms3652 KiB
17Accepted6/62ms3412 KiB