From 9dce6eaf425178ab1c37dc15b3a74f09e23e9243 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Fri, 6 May 2022 23:24:22 +0200 Subject: Added contests file --- contests/05-05-2022(Div.3)/B/B.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 contests/05-05-2022(Div.3)/B/B.cpp (limited to 'contests/05-05-2022(Div.3)/B/B.cpp') diff --git a/contests/05-05-2022(Div.3)/B/B.cpp b/contests/05-05-2022(Div.3)/B/B.cpp new file mode 100644 index 0000000..27c4853 --- /dev/null +++ b/contests/05-05-2022(Div.3)/B/B.cpp @@ -0,0 +1,48 @@ +#include + +using namespace std; + +bool isIncreasing(vector v){ + for(int i = 0; i < v.size() - 1; i++) { + if(v[i] >= v[i+1]) { + return false; + } + } + return true; +} +int getIndex(vector v){ + int index; + for(int i = 0; i < v.size(); i++) { + vector v2(i+1); + for(int j = 0; j <= i;j++){ + index = j; + v2[j] = v[j]; + } + if(!isIncreasing(v2)) { + return index; + } + } + return -1; +} + +int main () { + int tt, n; + cin >> tt; + while(tt--) { + cin >> n; + vector v(n); + for(auto &x : v) { + cin >> x; + } + int idx = getIndex(v); + vector rem(v.size() - idx); + if(idx == -1) { + cout << "0" << endl; + } else { + for(int i = 0;i < v.size() - idx; i++) { + rem[i] = v[idx + i]; + } + } + } + +} -- cgit v1.2.3