# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
439767 |
2021-06-30T19:07:19 Z |
gromperen |
Karte (COCI18_karte) |
C++14 |
|
423 ms |
33324 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, k; cin >> n >> k;
int t = k;
vector<int> a(n);
multiset<int> b;
b.insert(INF);
for (int i = 0; i < n; ++i) {
cin >> a[i];
b.insert(a[i]);
}
vector<int> ans;
for (int i = 0; i < n; ++i) {
int cur = *b.lower_bound(k);
if (cur == INF) cur = *b.begin();
ans.push_back(cur);
if (cur != k) k--;
b.erase(b.find(cur));
}
int cnt = 0;
for (int i = n-1; i >= 0; --i) {
if (ans[i] > cnt) cnt++;
}
if (cnt == t) {
for (int i = 0; i < n; ++i) cout << ans[i] << " ";
cout << "\n";
} else {
cout << "-1\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
6928 KB |
Output is correct |
2 |
Correct |
50 ms |
6592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
13584 KB |
Output is correct |
2 |
Correct |
142 ms |
12844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
423 ms |
33324 KB |
Output is correct |
2 |
Correct |
404 ms |
30856 KB |
Output is correct |