Submission #1094217

#TimeUsernameProblemLanguageResultExecution timeMemory
1094217Trisanu_DasFeast (NOI19_feast)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int a[n]; for(int i = 0; i < n; i++) cin >> a[i]; int ans = 0, curr = 0, sm = 0; for(int i = 0; i < n; i++){ if(a[i] >= 0) sm += a[i]; curr += a[i]; ans = max(ans, curr); curr = max(curr, 0); } if(k == 1) cout << ans << '\n'; else cout << sm << '\n'; }

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:14:23: error: no matching function for call to 'max(long long int&, int)'
   14 |     curr = max(curr, 0);
      |                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
feast.cpp:14:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |     curr = max(curr, 0);
      |                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
feast.cpp:14:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |     curr = max(curr, 0);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from feast.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
feast.cpp:14:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |     curr = max(curr, 0);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from feast.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
feast.cpp:14:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |     curr = max(curr, 0);
      |                       ^