Submission #730646

#TimeUsernameProblemLanguageResultExecution timeMemory
730646stefdascaKarte (COCI18_karte)C++14
120 / 120
114 ms13828 KiB
#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)

karte.cpp: In function 'int main()':
karte.cpp:49:5: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   49 |     else
      |     ^~~~
karte.cpp:51:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   51 |  return 0;
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...