Submission #98171

#TimeUsernameProblemLanguageResultExecution timeMemory
98171dalgerokKarte (COCI18_karte)C++17
120 / 120
141 ms7796 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n, k; cin >> n >> k; int a[n + 1]; for(int i = 1; i <= n; i++){ cin >> a[i]; } sort(a + 1, a + n + 1); reverse(a + 1 + n - k, a + n + 1); int ans = 0; for(int i = n; i >= 1; i--){ ans += (a[i] > ans); } if(ans != k){ return cout << "-1", 0; } for(int i = 1; i <= n; i++){ cout << a[i] << " "; } }
#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...