Created
November 29, 2018 06:20
-
-
Save limabeans/cbb2b099f88a9bd1c4081a563d8ccb24 to your computer and use it in GitHub Desktop.
uva10684
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
template<typename T> | |
void out(T x) { cout << x << endl; exit(0); } | |
const int maxn=(int)4e5+5; | |
int main() { | |
ios_base::sync_with_stdio(false); cin.tie(0); | |
//cout << fixed << setprecision(6); | |
int n; | |
while (1) { | |
cin>>n; | |
if (n==0) return 0; | |
vector<int> nums(n); | |
for (int i=0; i<n; i++) cin>>nums[i]; | |
int cur = 0; | |
int ans = 0; | |
for (int i=0; i<n; i++) { | |
cur += nums[i]; | |
ans = max(cur, ans); | |
if (cur < 0) cur = 0; | |
} | |
if (ans>0) { | |
cout<<"The maximum winning streak is "<<ans<<"."<<endl; | |
} else { | |
cout<<"Losing streak."<<endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment