-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday37.cpp
More file actions
39 lines (31 loc) · 824 Bytes
/
day37.cpp
File metadata and controls
39 lines (31 loc) · 824 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
#include <iostream>
#include <vector>
using namespace std;
int longestNonDecreasingSubarray(vector<int>& flow) {
int n = flow.size();
int maxLength = 1, currentLength = 1;
for (int i = 1; i < n; ++i) {
if (flow[i] >= flow[i - 1]) {
currentLength++;
} else {
currentLength = 1;
}
maxLength = max(maxLength, currentLength);
}
return maxLength;
}
int main() {
int t; // Number of test cases
cin >> t;
while (t--) {
int n; // Number of points along the Nile
cin >> n;
vector<int> flow(n);
for (int i = 0; i < n; ++i) {
cin >> flow[i];
}
// Calculate and output the result for this test case
cout << longestNonDecreasingSubarray(flow) << endl;
}
return 0;
}