CSES - KILO 2017 2/5 - Results
Submission details
Task:Odd sequence
Sender:rip
Submission time:2017-09-12 16:55:16 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:17: error: no matching function for call to 'max(int, long long int)'
   o = max(0, e+a);
                 ^
input/code.cpp:13:17: note: candidates are:
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/sstream:38,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from input/code.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:   template argument deduction/substitution failed:
input/code.cpp:13:17: note:   deduced conflicting types fo...

Code

#include <bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long V=-1e9, o = 0, e = -1e9;
	for(int i=0; i<n; ++i){
		long long a; cin >> a;
		long long c = e;
		c = o;
		o = max(0, e+a);
		e = c+a;
		V = max(V, e);
	}
	cout << V;
}