-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBestSubsegment.cpp
More file actions
40 lines (37 loc) · 845 Bytes
/
Copy pathBestSubsegment.cpp
File metadata and controls
40 lines (37 loc) · 845 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
// https://codeforces.com/contest/1117/problem/A
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// Doesn't make sense to take anything less than the max value!
void solveCase() {
int n;
cin >> n;
vector<int> a(n);
for (int& a_i : a) {
cin >> a_i;
}
int max_val = 0;
for (int a_i : a) {
max_val = max(max_val, a_i);
}
int ans = 1;
for (int i = 1, curr = 1; i < n; ++i) {
if (a[i] == max_val && a[i-1] == a[i]) {
ans = max(ans, ++curr);
} else {
curr = 1;
}
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int nC = 1;
// cin >> nC;
for (int i = 1; i <= nC; i++) {
// cout << "\nTEST #" << i << ":\n";
solveCase();
}
return 0;
}