Submission #104684

#TimeUsernameProblemLanguageResultExecution timeMemory
104684IVIosabKarte (COCI18_karte)C++17
120 / 120
129 ms6860 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define mp make_pair #define ll long long int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin>>n>>k; int ar[n]; for(int i=0;i<n;i++){ cin>>ar[i]; } sort(ar,ar+n); vector<int> v; for(int i=0;i<n-k;i++){ v.push_back(ar[i]); } for(int i=n-1;i>=n-k;i--){ v.push_back(ar[i]); } int fss=0,z=0; for(int i=n-1;i>=0;i--){ if(fss<v[i]){ fss++; z++; } } if(z!=k){ cout<<-1<<endl; } else{ for(int i=0;i<n;i++){ cout<<v[i]<<" "; } cout<<endl; } 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...