제출 #1178436

#제출 시각아이디문제언어결과실행 시간메모리
1178436PAndaSZalmoxis (BOI18_zalmoxis)C++20
0 / 100
66 ms6472 KiB
#include<iostream>
#include<vector>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> seq(n), cnt(31, 0);
    for(int i = 0; i < n; i++){
        cin >> seq[i];
        cnt[seq[i]]++;
    }
    int missing = -1;
    for(int i = 0; i < 31; i++){
        if(cnt[i] % 2){
            missing = i;
            break;
        }else{
            cnt[i + 1] += cnt[i] / 2;
            cnt[i] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        if(seq[i] < missing){
            cout << missing << ' ';
            missing = -1;
        }
        cout << seq[i] << ' ';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...