# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308661 | 2020-10-01T16:34:36 Z | shrek12357 | Karte (COCI18_karte) | C++14 | 377 ms | 7080 KB |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include <stack> using namespace std; #define ll long long //cin.tie(0); //ios_base::sync_with_stdio(0); bool comp(int a, int b) { return a > b; } int main() { int n, k; cin >> n >> k; vector<int> nums; //int counter = 0; for (int i = 0; i < n; i++) { int temp; cin >> temp; //if (temp == 0) { // counter++; // continue; //} nums.push_back(temp); } sort(nums.begin(), nums.end()); vector<int> temp = nums; sort(temp.begin(), temp.end(), comp); if (nums.size() < k) { cout << -1 << endl; return 0; } for (int i = n - k; i < n; i++) { if (nums[i] <= i - (n - k)) { cout << -1 << endl; return 0; } } for (int i = 0; i < n - k; i++) { if (nums[i] > k) { cout << -1 << endl; return 0; } } // for (int i = 0; i < counter; i++) { // cout << 0 << " "; // } for (int i = n - k - 1; i >= 0; i--) { cout << nums[i] << " "; } for (int i = n - 1; i >= n - k; i--) { cout << nums[i] << " "; } cout << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 1736 KB | Output is correct |
2 | Correct | 66 ms | 1264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 3048 KB | Output is correct |
2 | Correct | 132 ms | 2028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 377 ms | 7080 KB | Output is correct |
2 | Correct | 325 ms | 4608 KB | Output is correct |