답안 #200187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200187 2020-02-05T16:01:16 Z Saboon Karte (COCI18_karte) C++14
36 / 120
141 ms 10220 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn = 5e5 + 37;

int a[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	vector<int> A, B;
	int now = 0;
	for (int i = 1; i <= n; i++){
		if (a[i] > now){
			now = min(k, now + 1);
			A.push_back(a[i]);
			continue;
		}
		B.push_back(a[i]);
	}
	if (A.size() < k)
		return cout << -1 << endl, 0;
	reverse(A.begin(), A.end());
	while (A.size() > k){
		B.push_back(A.back());
		A.pop_back();
	}
	for (auto it : B)
		cout << it << " ";
	for (auto it : A)
		cout << it << " ";
	cout << endl;
}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (A.size() < k)
      ~~~~~~~~~^~~
karte.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (A.size() > k){
         ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 6 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 2380 KB Output is correct
2 Incorrect 33 ms 2544 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 4452 KB Output is correct
2 Incorrect 57 ms 4864 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 10220 KB Output is correct
2 Incorrect 134 ms 10220 KB Output isn't correct