Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- while (cin >> n) {
- int a, total, beg, end;
- total = beg = end = 0;
- for (int i = 1; i <= n; i++) {
- cin >> a;
- total += a; //total = total + a
- if (total >= beg) beg = total;
- else if (total <= end) end = total;
- }
- cout << beg << " " << (total - end) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement