Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #define endl "\n"
- using mii = map<int, int>;
- int main(int argc, const char * argv[]) {
- IOS
- int n, k, *a, mx;
- mii m; m.clear();
- cin >> n >> k;
- a = new int[n];
- mx = 0;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- m[a[i]]++;
- mx = max(mx, m[a[i]]);
- }
- if(mx <= k) {
- cout << "YES\n";
- m.clear();
- mii pt; pt.clear();
- for(int i = 0; i < n; i++) {
- if (i < k) {
- cout << i+1;
- pt[i+1] = a[i];
- } else {
- m[a[i]]++;
- while (pt[ m[a[i]] ] == a[i])
- m[a[i]]++;
- cout << m[a[i]];
- }
- cout << (i==n-1?'\n':' ');
- }
- } else {
- cout << "NO\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment