-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10684.cpp
More file actions
44 lines (33 loc) · 633 Bytes
/
10684.cpp
File metadata and controls
44 lines (33 loc) · 633 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 <iostream>
#include <cstdint>
#include <algorithm>
using namespace std;
int64_t dp[10010];
int64_t output;
int64_t input;
void solve();
int main() {
while (cin >> input) {
if (input == 0) {
break;
} else {
solve();
}
}
return 0;
}
void solve() {
fill(dp, (dp + input), 0);
for (int64_t i = 0; i < input; i++) {
cin >> dp[i];
}
for (int64_t i = 1; i < input; i++) {
dp[i] = max(dp[i], (dp[i] + dp[i - 1]));
}
output = *max_element(dp, (dp + input));
if (output <= 0) {
cout << "Losing streak." << endl;
} else {
cout << "The maximum winning streak is " << output << '.' << endl;
}
}