#include <bits/stdc++.h>
#define DIM 1000010
using namespace std;
int v[DIM];
int n,i,poz,sol,idx,k,sol_poz;
/*void solve (int val){
if (val == 1 || sol)
return;
if (v[idx] == val-1){
/// inseamna ca in stanga nu ma mai duc deloc
idx++;
} else {
/// pot sa ma duc
if (v[idx] > val-1){
sol = val-1, poz = idx-1;
return;
}
solve (val-1);
}
/// acum dreapta
if (v[idx] == val-1)
idx++;
else {
if (v[idx] > val-1){
sol = val-1, poz = idx-1;
return;
}
solve (val-1);
}
}*/
int solve (int val, int idx){
if (sol)
return 0;
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 (v[poz] > val || v[poz] == 0){
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
295 ms |
6392 KB |
not a zalsequence |
2 |
Incorrect |
297 ms |
6392 KB |
not a zalsequence |
3 |
Incorrect |
301 ms |
6520 KB |
not a zalsequence |
4 |
Incorrect |
297 ms |
6520 KB |
not a zalsequence |
5 |
Incorrect |
289 ms |
6524 KB |
not a zalsequence |
6 |
Incorrect |
286 ms |
6392 KB |
not a zalsequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
310 ms |
6264 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
297 ms |
6264 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
303 ms |
6392 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
293 ms |
6392 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
298 ms |
6392 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
301 ms |
6264 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
290 ms |
6392 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
299 ms |
6520 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
231 ms |
5112 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
93 ms |
2168 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
146 ms |
3320 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 |
376 KB |
Unexpected end of file - int32 expected |