-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequence.cpp
More file actions
48 lines (48 loc) · 827 Bytes
/
sequence.cpp
File metadata and controls
48 lines (48 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int m;
cin>>m;
int b[m];
int n=2*m;
int a[n];
for(int i=0;i<m;i++)
{
cin>>b[i];
}
a[0]=b[0];
int j=1;
for(int i=1;i<m;i++)
{
if(b[i-1]<=b[i])
{
a[j]=b[i];
j++;
}
else
{
int c=b[i]-1;
if(c==0)
{
a[j]=b[i];
j++;
}
a[j]=b[i];
j++;
}
}
cout<<j<<endl;
for(int i=0;i<j;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
}
//hbfdb