Submission #49675

# Submission time Handle Problem Language Result Execution time Memory
49675 2018-06-02T01:23:51 Z IvanC Karte (COCI18_karte) C++17
12 / 120
171 ms 11956 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> V,U;
int N,K,F,copia;

int main(){
	scanf("%d %d",&N,&K);
	copia = K;
	for(int i = 1;i<=N;i++){
		int a;
		scanf("%d",&a);
		V.push_back(a);
	}
	sort(V.begin(),V.end());
	while(copia > 0){
		if(V.empty()){
			printf("-1\n");
			return 0;
		}
		copia--;
		U.push_back(V.back());
		V.pop_back();
	}
	reverse(U.begin(),U.end());
	for(int i : V){
		U.push_back(i);
	}
	for(int i : U){
		if(F < i){
			F++;
		}
	}
	if(F != K) printf("-1\n");
	else{
		for(int i : U) printf("%d ",i);
		printf("\n");
	}
	return 0;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&N,&K);
  ~~~~~^~~~~~~~~~~~~~~
karte.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a);
   ~~~~~^~~~~~~~~
# 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 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 2600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 5180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 171 ms 11956 KB Output isn't correct
2 Halted 0 ms 0 KB -