제출 #750239

#제출 시각아이디문제언어결과실행 시간메모리
7502397as__7Zalmoxis (BOI18_zalmoxis)C++17
0 / 100
1087 ms8020 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...