Submission #57142

#TimeUsernameProblemLanguageResultExecution timeMemory
57142polyfishKarte (COCI18_karte)C++14
0 / 120
1064 ms8848 KiB
//I love armpit fetish #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " = " << x << '\n'; #define BP() cerr << "OK!\n"; #define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define FILE_NAME "data" const int MAX_N = 500002; int n, k, a[MAX_N]; void enter() { cin >> n >> k; for (int i=1; i<=n; ++i) cin >> a[i]; } bool check() { int false_claim = 0; PR(a, n); for (int i=n; i>=1; --i) { if (a[i]>false_claim) { ++false_claim; } } return false_claim == k; } void solve() { sort(a+1, a+n+1); reverse(a+n-k+1, a+n+1); if (check()) { for (int i=1; i<=n; ++i) cout << a[i] << ' '; } else { cout << -1; } } int main() { //#define OFFLINE_JUDGE doraemon #ifdef OFFLINE_JUDGE freopen(FILE_NAME".inp", "r", stdin); freopen(FILE_NAME".out", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); enter(); solve(); }
#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...