-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrecord_breaking.cpp
More file actions
59 lines (52 loc) · 1.78 KB
/
record_breaking.cpp
File metadata and controls
59 lines (52 loc) · 1.78 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Kick Start
Isyana is given the number of visitors at her local theme park on N consecutive days. The number of visitors on the i-th day is Vi. A day is record breaking if it satisfies both of the following conditions:
The number of visitors on the day is strictly larger than the number of visitors on each of the previous days.
Either it is the last day, or the number of visitors on the day is strictly larger than the number of visitors on the following day.
Note that the very first day could be a record breaking day!
Please help Isyana find out the number of record breaking days.
Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the integer N. The second line contains N integers. The i-th integer is Vi.
Output
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of record breaking days.
*/
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
{
int num;
cin >> num;
arr[i] = num;
}
int record = arr[0];
int record_ind = 0;
for (int i = 1; i < n - 1; i++)
{
bool cond1 = true;
bool cond2 = true;
for (int j = 0; j < i; j++)
{
if (arr[j] > arr[i])
{
cond1 = false;
}
}
if (arr[i] < arr[i + 1])
{
cond2 = false;
}
if (cond1 == true && cond2 == true && arr[i] > record)
{
record = arr[i];
record_ind = i;
}
}
cout << "record ele: " << record << endl;
cout << "record index: " << record_ind << endl;
return 0;
}