-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem-C.cpp
46 lines (40 loc) · 915 Bytes
/
Problem-C.cpp
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
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #define DEBUG
#define value(x) std::cerr << "Value of \"" << #x << "\" is " << x << '\n';
#define unto(i, begin, end) for (int i = begin; i < end; ++i)
#define print_array(array, begin, end) unto(i, begin, end) std::cout << array[i] << " \n"[i == end - 1];
int32_t main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
#ifdef DEBUG
printf("DEBUG was defined at compile time\n");
#endif // DEBUG
int tests_number;
std::cin >> tests_number;
while (tests_number--)
{
int n;
std::cin >> n;
std::vector <int> a;
for (int i = 0; i < n; ++i)
{
int element;
std::cin >> element;
a.push_back(element);
}
int ind = n - 1;
while (ind > 0 && a[ind] <= a[ind - 1])
{
--ind;
}
while (ind > 0 && a[ind] >= a[ind - 1])
{
--ind;
}
std::cout << ind << '\n';
}
return 0;
}