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;
const int N = 1e6 + 5;
int n, k, x;
vector<pair<int, int>> v, v2;
vector<int> nums[N], vec;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n >> k;
for(int i = 0; i < n; i++){
cin >> x;
nums[i].push_back(x);
v.push_back({x, i});
}
for(int num = 1; num <= 29; num++){
swap(v, v2);
v.clear();
for(auto p : v2){
if(v.empty()) v.push_back(p);
else{
if(v.back().first == num){
if(p.first == num){
v.back().first = num + 1;
v.back().second = p.second;
}
else{
v.back().first = num + 1;
nums[v.back().second].push_back(num);
v.push_back(p);
}
}
else v.push_back(p);
}
}
if(v.back().first == num){
v.back().first = num + 1;
nums[v.back().second].push_back(num);
}
}
for(int i = 0; i < n; i++){
for(auto j : nums[i]){
vec.push_back(j);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |