This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
const int sz = 1e6 + 1, mod = 1e9 + 7, inf = -1e18;
int dp[10001][1001] = {};
signed main()
{
int n, k;
cin >> n >> k;
vector<int>v(n);
map<int, pair<int,int>>mp;
for (int i = 0; i < n; i++) {
cin >> v[i];
mp[v[i]].first++;
if(!mp[v[i]].second)
mp[v[i]].second = i;
}
int x = 30 - n;
int ans = -1;
int idx = mp[x].second;
while (1) {
if (mp[x].first == 1) {
idx--;
ans = x;
break;
}
if (mp[x].first == 2) {
mp[x + 1].second = mp[x].second;
mp[x + 1].first++;
x++;
}
}
for (int i = 0; i < n; i++) {
cout << v[i] << ' ';
if (idx == i) {
cout << ans << ' ';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |