-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Sequence_Game.cpp
More file actions
40 lines (36 loc) · 802 Bytes
/
B_Sequence_Game.cpp
File metadata and controls
40 lines (36 loc) · 802 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<long long> b(n);
for (int i = 0; i < n; i++)
cin >> b[i];
vector<long long> a;
a.push_back(b[0]);
for (int i = 1; i < n; i++)
{
if (b[i - 1] <= b[i])
{
a.push_back(b[i]);
}
else
{
a.push_back(b[i - 1]); // big one first
a.push_back(b[i]); // then the smaller one
}
}
cout << a.size() << "\n";
for (long long x : a)
cout << x << " ";
cout << "\n";
}
return 0;
}