Submission #49737

# Submission time Handle Problem Language Result Execution time Memory
49737 2018-06-02T13:08:45 Z IvanC Karte (COCI18_karte) C++17
12 / 120
109 ms 5740 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);
	}
	reverse(U.begin(),U.end());
	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 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 2912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 5740 KB Output isn't correct
2 Halted 0 ms 0 KB -