Submission #602464

# Submission time Handle Problem Language Result Execution time Memory
602464 2022-07-23T06:24:01 Z starchan Karte (COCI18_karte) C++17
120 / 120
104 ms 5212 KB
#include<bits/stdc++.h>
using namespace std;
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
	fast();
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	a[0] = 0;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	sort(a.end()-k, a.end(), greater<int>());
	bool win = 1;
	for(int i = 1; i <= n; i++)
	{
		if(i <= n-k)
			win&=(k>=a[i]);
		else
			win&=(a[i]>(n-i));
	}
	if(win)
	{
		for(int i = 1; i <= n; i++)
			cout << a[i] << " ";
	}
	else
		cout << "-1";
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1104 KB Output is correct
2 Correct 14 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2088 KB Output is correct
2 Correct 30 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 4832 KB Output is correct
2 Correct 62 ms 5212 KB Output is correct