/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int niz[1000001];
int n;
int k;
int vis[1000001];
using pii = pair<int,pair<int,int>>;
int main()
{
cin >> n >> k;
priority_queue<pii, vector<pii> , greater<pii> > pq;
for(int i = 0; i < n; i++){
cin >> niz[i];
pq.push({niz[i],{i,i}});
}
int ans = -1;
int ind = -1;
int t1 = 0;
while(!pq.empty() and t1 == 0){
pii a = pq.top();
pq.pop();
if(pq.empty()){
ans = a.first;
ind = a.second.second;
t1++;
break;
}else{
pii b = pq.top();
pq.pop();
if(a.first != b.first){
ans = a.first;
ind = a.second.second;
t1++;
break;
}else{
int prvi = a.second.second + 1;
int drugi = b.second.first;
if(prvi == drugi){
pq.push({a.first + 1,{a.second.first,b.second.second}});
}else{
ans = a.first;
ind = a.second.second;
t1++;
break;
}
}
}
}
for(int i = 0; i < n; i++){
cout << niz[i] << " ";
if(ind == i){
cout << ans << " ";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
473 ms |
22216 KB |
Output is correct |
2 |
Correct |
480 ms |
22188 KB |
Output is correct |
3 |
Correct |
467 ms |
22168 KB |
Output is correct |
4 |
Correct |
467 ms |
21996 KB |
Output is correct |
5 |
Correct |
468 ms |
21996 KB |
Output is correct |
6 |
Correct |
480 ms |
21964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
461 ms |
22192 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
188 ms |
22452 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
196 ms |
22256 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
423 ms |
22312 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
451 ms |
21932 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
604 ms |
21932 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
455 ms |
21860 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
293 ms |
21936 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
151 ms |
19380 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
61 ms |
11452 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
93 ms |
13212 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
1 ms |
2396 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
1 ms |
2396 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
1 ms |
2396 KB |
Unexpected end of file - int32 expected |