Submission #639750

# Submission time Handle Problem Language Result Execution time Memory
639750 2022-09-11T13:24:34 Z Pietra Karte (COCI18_karte) C++14
120 / 120
190 ms 5368 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()) ; reverse(vec.begin(), vec.end()) ;
    reverse(vec.begin(), vec.begin()+k) ;

    int ctr = 0 ;

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

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

    for(int i = n-1 ; i >= 0 ; i--) cout << vec[i] << " " ;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 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 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1324 KB Output is correct
2 Correct 31 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 2160 KB Output is correct
2 Correct 61 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 190 ms 4944 KB Output is correct
2 Correct 153 ms 5368 KB Output is correct