Skip to content

Commit 7f23a99

Browse files
committed
Added 1841B - Keep it Beautiful.cpp
1 parent c881c0e commit 7f23a99

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

1841B - Keep it Beautiful.cpp

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
5+
#define ll long long
6+
#define pb push_back
7+
#define ff first
8+
#define ss second
9+
#define mp make_pair
10+
11+
// Code Written By: Vikash Patel
12+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
13+
14+
int main()
15+
{
16+
ios_base::sync_with_stdio(0);
17+
cin.tie(0);
18+
cout.tie(0);
19+
20+
// #ifndef ONLINE_JUDGE
21+
// freopen("input.txt", "r", stdin);
22+
// freopen("/Users/vikash/Desktop/output.txt", "w", stdout);
23+
// #endif
24+
25+
int t;
26+
cin>>t;
27+
while(t--)
28+
{
29+
int n;
30+
cin>>n;
31+
int num, flag = 0, first = -1, last = -1;
32+
while(n--)
33+
{
34+
cin>>num;
35+
if(flag)
36+
{
37+
if(num >= last and num <= first)
38+
{
39+
last = num;
40+
cout<<1;
41+
}
42+
else
43+
cout<<0;
44+
}
45+
else
46+
{
47+
if(first == -1)
48+
{
49+
first = num;
50+
last = num;
51+
cout<<1;
52+
}
53+
else if(num >= last)
54+
{
55+
last = num;
56+
cout<<1;
57+
}
58+
else if(first >= num)
59+
{
60+
last = num;
61+
flag = 1;
62+
cout<<1;
63+
}
64+
else
65+
cout<<0;
66+
}
67+
}
68+
cout<<endl;
69+
}
70+
return 0;
71+
}

0 commit comments

Comments
 (0)