Submission #139406

# Submission time Handle Problem Language Result Execution time Memory
139406 2019-07-31T16:11:19 Z path Karte (COCI18_karte) C++14
120 / 120
136 ms 7312 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef unsigned long long int ll;
const int N=5e5+5;
int n,k,a[N],b[N],lst,tmp,tmp2;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n-k;i++)
        b[i]=a[i];
    lst=n-k;
    for(int i=n-1;i>=n-k;i--,lst++)
        b[lst]=a[i];
    lst=0;
    for(int i=n-1;i>=0;i--)
        if(b[i]>lst)
            lst++;
    if(lst!=k)
        cout<<-1<<'\n';
    else{
        for(int i=0;i<n;i++)
            cout<<b[i]<<" ";
        cout<<'\n';
    }
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1656 KB Output is correct
2 Correct 20 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2924 KB Output is correct
2 Correct 39 ms 2040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 6820 KB Output is correct
2 Correct 89 ms 7312 KB Output is correct