Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // playground_abc
- //
- // Created by Maxim Tsygankov on 10/18/17.
- // Copyright © 2017 Maxim Tsygankov. All rights reserved.
- //
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <fstream>
- #include <string>
- #include <map>
- using namespace std;
- int main(int argc, const char * argv[]) {
- int n;
- cin >> n;
- int maxSum;
- cin >> maxSum;
- int curSum = maxSum;
- for (int i = 1; i < n; i++) {
- int num;
- cin >> num;
- if (curSum + num < num) {
- curSum = num;
- }else{
- curSum += num;
- }
- maxSum = max(maxSum, curSum);
- }
- cout << maxSum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement