Submission #639746

# Submission time Handle Problem Language Result Execution time Memory
639746 2022-09-11T12:53:36 Z Pietra Karte (COCI18_karte) C++14
0 / 120
175 ms 6840 KB
#include<bits/stdc++.h>
using namespace std ;
// o ideal eh começar decrescente
// o ideal eh o começo ter os certos
// se quiser mudar

const int maxn = 1e5 + 5 ;

int n, k, v[maxn], ct[maxn], used[maxn], seq[maxn] ;

// pga o menorr q satisfaz smp pros verdadeiros
// pros falos coloca os maiores mais a esq
int main(){

    cin >> n >> k ;

    vector<int> vec, vv ;

    for(int i = 0 ; i < n ; i++){
        int a ; cin >> a ;
        vec.push_back(a) ;
    }

    sort(vec.begin(), vec.end()) ;

    for(int i = n ; i >= n - k ; i--) v[i] = vec[i-1] ;

    for(int i = 1 ; i < n-k ; i++) vv.push_back(vec[i-1]) ;

    sort(vv.begin(), vv.end()) ;
    reverse(vv.begin(), vv.end()) ;

    for(int i = 1 ; i < n-k ; i++) v[i] = vv[i-1] ;

    bool ans = 1 ;

    int ctr = 0 ;

    for(int i = n ; i > 0 ; i--){
        if(v[i] >= ctr) continue ;
        else ctr++ ;
    }

    if(ctr != k){
        cout << "-1\n" ; exit(0) ;
    }

    for(int i = 1 ; i <= n ; i++) cout << v[i] << " " ;

}

Compilation message

karte.cpp: In function 'int main()':
karte.cpp:35:10: warning: unused variable 'ans' [-Wunused-variable]
   35 |     bool ans = 1 ;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 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 0 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 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 33 ms 1480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 63 ms 2696 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 175 ms 6840 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -