Submission #652405

# Submission time Handle Problem Language Result Execution time Memory
652405 2022-10-22T13:38:11 Z Johnson8033 Karte (COCI18_karte) C++14
0 / 120
117 ms 11584 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,k;
int a[500005],b[500005],vis[500005];
void solve(){
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for (int i=1,j=1;i<=k;i++,j++){
		while (a[j]<i&&j<=n) j++;
		if (j>n){
			cout<<-1<<endl;
			return;
		}
		b[n-i+1]=a[j];
		vis[j]=1;
	}
	for (int i=n,j=1;i>=1;i--){
		if (vis[i]) continue;
		b[j++]=a[i];
	}
	for (int i=1;i<=n;i++){
		cout<<b[i];
		if (i<n) cout<<" ";
		else cout<<endl;
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	// cin>>t;
	while (t--){
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 2528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 4776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 11584 KB Output isn't correct
2 Halted 0 ms 0 KB -