Submission #144449

# Submission time Handle Problem Language Result Execution time Memory
144449 2019-08-16T21:30:42 Z Ort Karte (COCI18_karte) C++11
120 / 120
133 ms 9956 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(c) (c).begin(),(c).end()
#define sz(a) ((int)(a.size()))
#define ll long long
#define LINF (ll)1e18
#define INF (int)1e9
#define MINF 0x3F3F3F3F
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 500005
#define watch(x) cerr<<#x<<" = "<<(x)<<endl;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n, k;

vector<int> arr, sol;

int main() {
	IO;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		int x; cin >> x;
		arr.pb(x);
	}
	sort(ALL(arr));
	for(int i=n-k;i<n;i++) {
        if(arr[i]<=sz(sol)) return cout << -1, 0;
        sol.push_back(arr[i]);
    }
    for(int i=0;i<n-k;i++) {
        if(arr[i]>k) return cout << -1, 0;
        sol.push_back(arr[i]);
    }
	for(int i=sz(sol)-1;i>=0;i--) cout << sol[i] << " ";
	return 0;
}
# 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 504 KB Output is correct
2 Correct 2 ms 348 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 3 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 3 ms 376 KB Output is correct
2 Correct 24 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2388 KB Output is correct
2 Correct 21 ms 1780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 4336 KB Output is correct
2 Correct 41 ms 3968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 133 ms 9956 KB Output is correct
2 Correct 98 ms 8424 KB Output is correct