Submission #486718

# Submission time Handle Problem Language Result Execution time Memory
486718 2021-11-12T13:34:13 Z perchuts Karte (COCI18_karte) C++17
0 / 120
1000 ms 4860 KB
#include <bits/stdc++.h>
#define maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf (int)(2e9+1)
#define mod (int)(1e9+7)

using namespace std;
int v[5*maxn],ans[5*maxn];
set<int>cards;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        v[x]++;
        cards.insert(x);
    }
    for(int i=0;i<k;i++){
        auto it=lower_bound(all(cards),i+1);
        if(it==cards.end()){
            cout<<"-1"<<endl;
            return 0;
        }else{
            v[*it]--;
            ans[i]=*it;
            if(v[*it]==0){
                cards.erase(*it);
            }
        }       
    }
    int ind=k;
    for(int i=0;i<=n;i++){
        while(v[i]){
            ans[ind++]=i;
            v[i]--;
        }
    }
    reverse(ans,ans+n);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 2948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 4860 KB Time limit exceeded
2 Halted 0 ms 0 KB -