Submission #3606627
Source Code Expand
#include <iostream> #include <algorithm> typedef long long ll; using namespace std; int main() { ll n, x, cnt = 0, prev = 0, now; cin >> n >> x; for (ll i = 0; i < n; ++i) { cin >> now; cnt += max(prev + now - x, 0); prev = now - max(prev + now - x, 0); } cout << cnt << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Boxes and Candies |
User | kyuko_haboro |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 358 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:37: error: no matching function for call to ‘max(ll, int)’ cnt += max(prev + now - x, 0); ^ In file included from /usr/include/c++/5/bits/char_traits.h:39:0, from /usr/include/c++/5/ios:40, from /usr/include/c++/5/ostream:38, from /usr/include/c++/5/iostream:39, from ./Main.cpp:1: /usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/5/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: ./Main.cpp:13:37: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’) cnt += max(prev + now - x, 0); ^ In file included from /usr/include/c++/5/bits/char_traits.h:39:0, from /usr/include/...