# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726992 | 2023-04-19T19:03:44 Z | buffering | Karte (COCI18_karte) | C++17 | 122 ms | 13892 KB |
#include <bits/stdc++.h> using namespace std; void IO(string s = "") { if (s == "") { freopen("input.txt", "r", stdin); freopen("output 2.txt", "w", stdout); } if (s != "") { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } } int main() { ios::sync_with_stdio(false); cin.tie(0); //IO(); int n; int 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 (int x: a) vals.push_back(x); for (int 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 << endl; } else cout << -1 << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 3068 KB | Output is correct |
2 | Correct | 16 ms | 2368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 5824 KB | Output is correct |
2 | Correct | 37 ms | 4608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 122 ms | 13892 KB | Output is correct |
2 | Correct | 75 ms | 11228 KB | Output is correct |