#include <bits/stdc++.h>
#define DIM 1000010
using namespace std;
int v[DIM];
int n,i,poz,sol,k,sol_poz;
int solve (int val, int idx){
if (v[idx] == val) /// nu mai pot sa ma duc in stanga ca am deja valoarea
return idx + 1;
if (!val)
return 0;
/// stanga
val--;
int poz = solve (val,idx);
if (poz > n || v[poz] > val){
/// sunt obligata sa pun aici val
sol = val;
sol_poz = poz-1;
return poz;
}
/// dreapta
return solve (val,poz);
}
int main (){
//ifstream cin ("zalmoxis.in");
// ofstream cout ("zalmoxis.out");
cin>>n>>k;
for (i=1;i<=n;i++)
cin>>v[i];
//idx = 1;
solve (30,1);
for (i=1;i<=n;i++){
cout<<v[i]<<" ";
if (i == sol_poz)
cout<<sol<<" ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
329 ms |
6392 KB |
Output is correct |
2 |
Correct |
315 ms |
6392 KB |
Output is correct |
3 |
Correct |
326 ms |
6392 KB |
Output is correct |
4 |
Correct |
304 ms |
6392 KB |
Output is correct |
5 |
Correct |
317 ms |
6392 KB |
Output is correct |
6 |
Correct |
308 ms |
6264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
312 ms |
6264 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
304 ms |
6264 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
332 ms |
6344 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
302 ms |
6392 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
311 ms |
6392 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
333 ms |
6320 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
318 ms |
6392 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
309 ms |
6404 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
246 ms |
5112 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
101 ms |
2168 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
164 ms |
3292 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
5 ms |
256 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
5 ms |
256 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
5 ms |
256 KB |
Unexpected end of file - int32 expected |