#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7
using namespace std;
ll n,k,ar[N],orig[N];
set < pi > s;
ll epomeno[N],proigoumeno[N];
vector < pi > res;
void solve()
{
if((*s.begin()).first == 30)
return;
set < pi >::iterator it = s.begin();
pi cur = *it;
swap(cur.first,cur.second);
// cout << cur.first << " " << cur.second << endl;
if(epomeno[cur.first] != n && ar[epomeno[cur.first]] == cur.second)
{
epomeno[cur.first] = epomeno[epomeno[cur.first]];
s.erase(s.begin());
}
else
{
res.push_back(mp(cur.first,cur.second));
}
s.erase(s.begin());
s.insert(mp(cur.second+1,cur.first));
ar[cur.first]++;
solve();
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> k;
rep(i,0,n)
{
cin >> ar[i];
orig[i] = ar[i];
epomeno[i] = i+1;
proigoumeno[i+1] = i;
s.insert(mp(ar[i],i));
}
solve();
ll cur = 0;
rep(i,0,n)
{
while(cur < res.size()&&res[cur].first <= i)
{
cout << res[cur].second << " ";
cur++;
}
cout << orig[i] << " ";
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(cur < res.size()&&res[cur].first <= i)
~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
237 ms |
48376 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
273 ms |
48120 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
275 ms |
48120 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
285 ms |
48128 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
231 ms |
48028 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
251 ms |
48120 KB |
Unexpected end of file - int32 expected |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
229 ms |
48096 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
225 ms |
48272 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
268 ms |
48260 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
236 ms |
48072 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
230 ms |
47992 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
230 ms |
48120 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
228 ms |
48248 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
235 ms |
48248 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
239 ms |
52204 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
320 ms |
59752 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
261 ms |
55752 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
380 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |