제출 #1177778

#제출 시각아이디문제언어결과실행 시간메모리
1177778tamzidFeast (NOI19_feast)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using ll = long long; #define pb push_back #define F first #define S second #define vii vector<int> #define vl vector<long long> #define cinv(v) for (auto &it : v) cin >> it; #define coutv(v) for (auto &it : v) cout << it << " "; cout << endl; using namespace std; //using namespace __gnu_pbds; //template<class T> using ordset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; void solve() { int n,k; cin>>n>>k; ll ans = 0; ll temp = 0; ll save = -1; for(int i=0;i<n;++i) { ll x; cin>>x; if(x>=0) { ans+=x; } else { if(k==1) { ll temp = ans; } save = x; } } cout<<max({ans,temp,ans+temp+x}); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); //int t;cin>>t;while(t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

feast.cpp: In function 'void solve()':
feast.cpp:40:34: error: 'x' was not declared in this scope
   40 |     cout<<max({ans,temp,ans+temp+x});
      |                                  ^
feast.cpp:40:14: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   40 |     cout<<max({ans,temp,ans+temp+x});
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
feast.cpp:40:14: note:   candidate expects 2 arguments, 1 provided
   40 |     cout<<max({ans,temp,ans+temp+x});
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from feast.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
feast.cpp:40:14: note:   candidate expects 3 arguments, 1 provided
   40 |     cout<<max({ans,temp,ans+temp+x});
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from feast.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed: