Created
September 26, 2017 18:38
-
-
Save mhmoodlan/6047da3ab05b81d25cd51cb2ae53dbd6 to your computer and use it in GitHub Desktop.
#MIS #MIS1D #UVa #Solved
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
//https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1625 | |
#include <bits/stdc++.h> | |
#define ll long long | |
#define sz(v) ((int) ((v).size())) | |
#define clr(v, d) memset(v, d, sizeof(v)) | |
#define lp(i, n) for(int i = 0; i < (int)(n); ++i) | |
#define rep(i, v) for(int i = 0; i < sz(v); ++i) | |
using namespace std; | |
const int MAX = 15; | |
const int OO = 1e4; | |
int n, m; | |
int main() { | |
int x, best, sum; | |
while(cin>>n && n!= 0) { | |
best = 0; | |
sum = 0; | |
lp(i, n) { | |
cin>>x; | |
if(sum < 0) sum = x; | |
else sum += x; | |
if(sum > best) best = sum; | |
} | |
if(best) | |
cout << "The maximum winning streak is " << best << "." << 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