# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730646 | stefdasca | Karte (COCI18_karte) | C++14 | 114 ms | 13828 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> nums(n);
for (int i = 0; i < n; i++)
cin >> nums[i];
sort(nums.begin(), nums.end());
int correct = n - m;
vector<int> a;
for (int i = correct - 1; i >= 0; i--)
a.push_back(nums[i]);
vector<int> b;
for (int i = n - 1; i >= correct; i--)
b.push_back(nums[i]);
vector<int> vals;
for (auto x: a)
vals.push_back(x);
for (auto x: b)
vals.push_back(x);
int bad = 0;
for (int i = n - 1; i >= 0; i--)
if (vals[i] > bad)
bad++;
if (bad == m)
{
for (int i = 0; i < n; i++)
cout << vals[i] << " ";
cout << '\n';
}
else
cout << -1 << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |