제출 #204882

#제출 시각아이디문제언어결과실행 시간메모리
204882egekabasCandies (JOI18_candies)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<ll, ll> pii; typedef pair<ld, ld> pld; ll prt[200009]; ll val[200009]; ll lef[200009]; ll rig[200009]; ll evsum[200009]; ll oddsum[200009]; ll findprt(ll x){ if(prt[x] == x) return x; return (prt[x] = findprt(prt[x])); } void merge(ll x, ll y){ x = findprt(x); y = findprt(y); if(x == y) return; prt[x] = y; val[y] += val[x]; lef[y] = min(lef[x], lef[y]); rig[y] = max(rig[x], rig[y]); evsum[y] += evsum[x]; oddsum[y] += oddsum[x]; } ll n; ll a[200009]; ll ans[200009]; set<pll, greater<pll>> s; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); cin >> n; for(ll i = 0; i < n; ++i){ cin >> a[i]; prt[i] = i; val[i] = a[i]; lef[i] = rig[i] = i; if(i%2) oddsum[i] = a[i]; else evsum[i] = a[i]; s.insert({val[i], i}); } ll sz = 1; ll cur = 0; while(sz <= (n+1)/2){ pll curit = *s.begin(); s.erase(s.begin()); ll curnode = curit.ss; if((lef[curnode] == 0 || rig[curnode] == n-1) && (rig[curnode]-lef[curnode])%2 ){ if(curit.ff <= 0) continue; } else{ ans[sz] = max(ans, cur); ++sz; } cur += curit.ff; //cout << lef[curnode] << ' ' << rig[curnode] << '\n'; ll befl = lef[curnode]; if(lef[curnode]-1 >= 0){ ll x = findprt(lef[curnode]-1); assert(s.erase({val[x], x}) == 1); merge(x, curnode); } curnode = findprt(curnode); if(rig[curnode]+1 < n){ ll x = findprt(rig[curnode]+1); assert(s.erase({val[x], x}) == 1); merge(x, curnode); } curnode = findprt(curnode); if(befl%2 == 0) val[curnode] = oddsum[curnode]-evsum[curnode]; else val[curnode] = evsum[curnode]-oddsum[curnode]; s.insert({val[curnode], curnode}); } for(ll i = 1; i <= (n+1)/2; ++i) cout << ans[i] << '\n'; }

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

candies.cpp: In function 'int main()':
candies.cpp:72:35: error: no matching function for call to 'max(ll [200009], ll&)'
             ans[sz] = max(ans, cur);
                                   ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from candies.cpp:1:
/usr/include/c++/7/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++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
candies.cpp:72:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int [200009]' and 'll {aka long long int}')
             ans[sz] = max(ans, cur);
                                   ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from candies.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
candies.cpp:72:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int [200009]' and 'll {aka long long int}')
             ans[sz] = max(ans, cur);
                                   ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from candies.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
candies.cpp:72:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'll* {aka long long int*}'
             ans[sz] = max(ans, cur);
                                   ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from candies.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
candies.cpp:72:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'll* {aka long long int*}'
             ans[sz] = max(ans, cur);
                                   ^