Submission #168322

# Submission time Handle Problem Language Result Execution time Memory
168322 2019-12-12T12:06:33 Z muhi1112 Karte (COCI18_karte) C++17
120 / 120
131 ms 5864 KB
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5+5;

vector<int>v;
int fals,n,k,a;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		v.pb(a);
	}
	sort(v.begin(),v.end());
	reverse(v.begin()+n-k,v.end());
	for(int i=n-1;i>=0;i--){
		if(v[i]>fals)fals++;
	}
	if(fals==k){
		for(int i=0;i<n;i++){
			cout<<v[i]<<" ";
		}
		return 0;
	}
	cout<<-1<<endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 296 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1968 KB Output is correct
2 Correct 21 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3184 KB Output is correct
2 Correct 39 ms 2340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 5864 KB Output is correct
2 Correct 92 ms 3440 KB Output is correct