95982024-02-23 14:08:44csaron71Kombináció (50)cpp17Wrong answer 33/503ms3888 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
base33/50
1Wrong answer0/03ms1808 KiB
2Wrong answer0/03ms2060 KiB
3Partially correct1/23ms2272 KiB
4Accepted2/23ms2484 KiB
5Accepted2/23ms2972 KiB
6Accepted2/23ms3096 KiB
7Partially correct1/23ms2992 KiB
8Partially correct1/22ms2992 KiB
9Accepted2/23ms3244 KiB
10Accepted4/43ms3208 KiB
11Partially correct2/43ms3212 KiB
12Partially correct2/43ms3396 KiB
13Accepted4/43ms3484 KiB
14Partially correct2/43ms3544 KiB
15Partially correct2/43ms3668 KiB
16Partially correct3/63ms3676 KiB
17Partially correct3/63ms3888 KiB