#include <bits/stdc++.h>
#define ll long long
#define MAXN 1000010
using namespace std;
map<ll,vector<ll> > m;
ll a[MAXN];
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,k,x;
cin >> n >> k;
priority_queue<pair<ll,pair<ll,ll> >,vector<pair<ll,pair<ll,ll> > >,greater<pair<ll,pair<ll,ll> > > > q;
for (ll i=1;i<=n;i++)
{
cin >> a[i];
q.push({a[i],{i,i}});
}
while (true)
{
auto t=q.top();
q.pop();
if (q.empty())
{
x=t.first;
break;
}
if (q.top().first!=t.first || q.top().second.first!=t.second.second+1)
{
m[t.second.second].push_back(t.first);
t.first++;
q.push(t);
k--;
continue;
}
t.second.second=q.top().second.second;
q.pop();
t.first++;
q.push(t);
}
for (ll i=1;i<=n;i++)
{
cout << a[i] << " ";
for (ll j=0;j<m[i].size();j++)
cout << m[i][j] << " ";
}
if (x!=30)
{
for (ll i=0;i<30;i++)
{
if (k&(1<<i))
{
for (ll j=0;j<(1<<i);j++)
cout << 29-i-1 << " ";
}
}
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:43:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (ll j=0;j<m[i].size();j++)
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
817 ms |
112000 KB |
Output is correct |
2 |
Correct |
823 ms |
111952 KB |
Output is correct |
3 |
Correct |
837 ms |
111904 KB |
Output is correct |
4 |
Correct |
815 ms |
111900 KB |
Output is correct |
5 |
Correct |
842 ms |
111980 KB |
Output is correct |
6 |
Correct |
806 ms |
111900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
831 ms |
111880 KB |
Unexpected end of file - int32 expected |
2 |
Correct |
765 ms |
111980 KB |
Output is correct |
3 |
Incorrect |
785 ms |
111908 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
923 ms |
112128 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
938 ms |
111980 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
826 ms |
111976 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
874 ms |
111964 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
803 ms |
111912 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
748 ms |
93344 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
322 ms |
38044 KB |
not a zalsequence |
11 |
Incorrect |
486 ms |
60312 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
57 ms |
2696 KB |
not a zalsequence |
13 |
Incorrect |
56 ms |
2688 KB |
not a zalsequence |
14 |
Incorrect |
56 ms |
2764 KB |
not a zalsequence |