Submission #1018706

# Submission time Handle Problem Language Result Execution time Memory
1018706 2024-07-10T08:44:52 Z vjudge1 Karte (COCI18_karte) C++17
0 / 120
134 ms 14776 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	multiset<int> se;
	for (int i=n-1;i>n-1-k;i--)
		se.insert(a[i]);
	int cnt[k+1]={};
	for (int i=0;i<n-k;i++)
	{
		if (a[i]>k)
			return cout<<-1<<endl, 0;
		cnt[a[i]]++;
	}
	vector<int> ans;
	for (int i=0;i<=k;i++)
	{
		while (cnt[i]--)
			ans.push_back(i);
		if (i<k)
		{
			auto x=se.begin();
			if (*x<=i)
			{
				cout<<-1<<endl;
				return 0;
			}
			ans.push_back(*x);
			se.erase(x);
		}
	}
	for (int i:ans)
		cout<<i<<' ';
	cout<<endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 4220 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 6852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 14776 KB Output isn't correct
2 Halted 0 ms 0 KB -