From 434b66191b0d3ca7945c1b2e019e08287168c8f2 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Wed, 7 Jun 2023 20:14:33 +0600 Subject: [PATCH] initial commit --- 1833C-VladBuildingBeautifulArray/1833C.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 1833C-VladBuildingBeautifulArray/1833C.cpp diff --git a/1833C-VladBuildingBeautifulArray/1833C.cpp b/1833C-VladBuildingBeautifulArray/1833C.cpp new file mode 100644 index 0000000..54655ed --- /dev/null +++ b/1833C-VladBuildingBeautifulArray/1833C.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; + +int main() +{ + int t; + cin >> t; + while (t--) + { + int n, i, min_even = 0, min_odd = 0, odd_count = 0, even_count = 0; + cin >> n; + int a[n]; + for (i = 0; i < n; i++) + { + cin >> a[i]; + if (a[i] % 2 != 0) + { + odd_count++; + if (odd_count == n) + break; + if (min_odd == 0 || min_odd > a[i]) + { + min_odd = a[i]; + } + } + else + { + even_count++; + if (even_count == n) + break; + if (min_even == 0 || min_even > a[i]) + { + min_even = a[i]; + } + } + } + if (odd_count == n || even_count == n || min_even > min_odd) + cout << "Yes" << endl; + else + cout << "No" << endl; + } +} \ No newline at end of file