-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBreakingTheRecords.cpp
More file actions
44 lines (37 loc) · 880 Bytes
/
Copy pathBreakingTheRecords.cpp
File metadata and controls
44 lines (37 loc) · 880 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
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
vector < int > getRecord(vector < int > s){
// Complete this function
vector<int> ans;
int maxiCount = 0, miniCount = 0, n = s.size();
int maxi = s[0], mini = s[0];
for(int i = 1; i < n; i++){
if(s[i] > maxi){
maxiCount++;
maxi = s[i];
}
else if(s[i] < mini){
miniCount++;
mini = s[i];
}
}
ans.push_back(maxiCount);
ans.push_back(miniCount);
return ans;
}
int main() {
int n;
cin >> n;
vector<int> s(n);
for(int s_i = 0; s_i < n; s_i++){
cin >> s[s_i];
}
vector < int > result = getRecord(s);
string separator = "", delimiter = " ";
for(auto val: result) {
cout<<separator<<val;
separator = delimiter;
}
cout<<endl;
return 0;
}