Submission #735644

#TimeUsernameProblemLanguageResultExecution timeMemory
735644tvladm2009Karte (COCI18_karte)C++17
24 / 120
81 ms5984 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 5e5; int A[N_MAX + 2]; int B[N_MAX + 2]; int C[N_MAX + 2]; int N, K; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for (int i = 1; i <= N; i++) { cin >> A[i]; } sort(A + 1, A + N + 1); for (int i = 1; i <= N - K; i++) { B[i] = A[K + i]; } sort(A + 1, A + K + 1); reverse(A + 1, A + K + 1); sort(B + 1, B + N - K + 1); reverse(B + 1, B + N - K + 1); for (int i = 1; i <= K; i++) { C[i] = A[i]; } for (int i = 1; i <= N - K; i++) { C[K + i] = B[i]; } int cnt = 0; for (int i = N; i >= 1; i--) { if (C[i] > cnt) { cnt++; } } if (cnt != K) { cout << "-1\n"; } else { for (int i = 1; i <= N; i++) { cout << C[i] << " "; } } 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...