# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885508 | 2023-12-09T22:03:20 Z | vjudge1 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | Compilation error |
0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define int long long struct Segment_tree { struct node { int value, lazy; node(int v = 0) { value = v; lazy = 0; } }; vector <node> tree; int l; void update(int v, int s, int e, int k) { tree[v].lazy += k; tree[v].value += (e - s + 1) * k; } void push(int v, int s, int e) { if (tree[v].lazy) { int middle = (s + e) / 2; update(2 * v, s, middle, tree[v].lazy); update(2 * v + 1, middle + 1, e, tree[v].lazy); tree[v].lazy = 0; } } void increase(int node, int v, int x, int y, int s, int e) { if (x > e || y < s) return; if (s >= x && e <= y) { update(node, s, e, v); return; } push(node, s, e); int middle = (s + e) / 2; increase(node * 2, v, x, y, s, middle); increase(node * 2 + 1, v, x, y, middle + 1, e); tree[node].value = tree[node * 2].value + tree[node * 2 + 1].value; } void increase(int x, int y, int v) { increase(1, v, x, y, 1, l); } int sum(int node, int x, int y, int s, int e) { if (x > e || y < s) return 0; if (s >= x && e <= y) return tree[node].value; push(node, s, e); int middle = (s + e) / 2; return sum(node * 2, x, y, s, middle) + sum(node * 2 + 1, x, y, middle + 1, e); } int query(int x) { return sum(1, x, x, 1, l); } Segment_tree(int n) { for (l = 1; l < n; l = (l << 1)); tree.resize(2 * l); } }; int32_t main() { ll n,q,s,t; cin>>n>>q>>s>>t; ll cad[n+1]; Segment_tree asd(n+2); for(int i=0; i<n+1; i++) { cin>>cad[i]; } ll u=0,d=0; for(int i=1; i<=n; i++) { u+=max(cad[i]-cad[i-1],0LL); d+=max(cad[i-1]-cad[i],0LL); asd.increase(i+1,i+1,cad[i]); } while(q--) { ll a,b,c; cin>>a>>b>>c; a++; b++; u-=max(asd.query(a)-asd.query(a-1),0); d-=max(asd.query(a-1)-asd.query(a),0); if(b!=n+1){ u-=max(asd.query(b+1)-asd.query(b),0); d-=max(asd.query(b)-asd.query(b+1),0);} asd.increase(a,b,c); u+=max(asd.query(a)-asd.query(a-1),0); d+=max(asd.query(a-1)-asd.query(a),0); if(b!=n+1){ u+=max(asd.query(b+1)-asd.query(b),0); d+=max(asd.query(b)-asd.query(b+1),0);} cout<<-u*s+d*t<<"\n"; } }
Compilation message
foehn_phenomena.cpp: In function 'int32_t main()': foehn_phenomena.cpp:109:45: error: no matching function for call to 'max(long long int, int)' 109 | u-=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:109:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 109 | u-=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:109:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 109 | u-=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:109:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 109 | u-=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:109:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 109 | u-=max(asd.query(a)-asd.query(a-1),0); | ^ foehn_phenomena.cpp:110:45: error: no matching function for call to 'max(long long int, int)' 110 | d-=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:110:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 110 | d-=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:110:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 110 | d-=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:110:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 110 | d-=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:110:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 110 | d-=max(asd.query(a-1)-asd.query(a),0); | ^ foehn_phenomena.cpp:112:45: error: no matching function for call to 'max(long long int, int)' 112 | u-=max(asd.query(b+1)-asd.query(b),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 foehn_phenomena.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: foehn_phenomena.cpp:112:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 112 | u-=max(asd.query(b+1)-asd.query(b),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 foehn_phenomena.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: foehn_phenomena.cpp:112:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 112 | u-=max(asd.query(b+1)-asd.query(b),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 foehn_phenomena.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: foehn_phenomena.cpp:112:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 112 | u-=max(asd.query(b+1)-asd.query(b),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 foehn_phenomena.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: foehn_phenomena.cpp:112:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 112 | u-=max(asd.query(b+1)-asd.query(b),0); | ^ foehn_phenomena.cpp:113:45: error: no matching function for call to 'max(long long int, int)' 113 | d-=max(asd.query(b)-asd.query(b+1),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 foehn_phenomena.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: foehn_phenomena.cpp:113:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 113 | d-=max(asd.query(b)-asd.query(b+1),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 foehn_phenomena.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: foehn_phenomena.cpp:113:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 113 | d-=max(asd.query(b)-asd.query(b+1),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 foehn_phenomena.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: foehn_phenomena.cpp:113:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 113 | d-=max(asd.query(b)-asd.query(b+1),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 foehn_phenomena.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: foehn_phenomena.cpp:113:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 113 | d-=max(asd.query(b)-asd.query(b+1),0);} | ^ foehn_phenomena.cpp:117:45: error: no matching function for call to 'max(long long int, int)' 117 | u+=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:117:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 117 | u+=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:117:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 117 | u+=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:117:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 117 | u+=max(asd.query(a)-asd.query(a-1),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 foehn_phenomena.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: foehn_phenomena.cpp:117:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 117 | u+=max(asd.query(a)-asd.query(a-1),0); | ^ foehn_phenomena.cpp:118:45: error: no matching function for call to 'max(long long int, int)' 118 | d+=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:118:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 118 | d+=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:118:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 118 | d+=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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: foehn_phenomena.cpp:118:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 118 | d+=max(asd.query(a-1)-asd.query(a),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 foehn_phenomena.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_