Submission #580198

# Submission time Handle Problem Language Result Execution time Memory
580198 2022-06-20T17:23:25 Z MrM7md Karte (COCI18_karte) C++17
12 / 120
115 ms 6748 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl "\n"

const int MOD = 1e9 + 7;

int frq[1000050];
signed main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n,k;
   cin >> n >> k;
   int a[n];
   for(int i=0;i<n;i++)cin>>a[i];
   sort(a,a+n,greater<int>());
   int f=0;
   int id=0;
   for(int i=n-1;i>=0;i--){
      if(f<a[i]){
         f++;
      }
      if(f==k)id=i;
   }

   if(f==k){
      for(int i=0;i<n;i++){
         cout<<a[i]<<' ';
      }
   }
   else if(f<k){
      cout<<-1;
   }
   else{
      sort(a,a+id+2);
      for(int i=0;i<n;i++){
         cout<<a[i]<<' ';
      }
   }


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 2780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -