Submission #890531

#TimeUsernameProblemLanguageResultExecution timeMemory
890531LucaIlieFood Court (JOI21_foodcourt)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3e5; long long v[MAX_N + 1]; struct SegTree { struct info { long long sum, minn; info operator + ( info &x ) { info ans; ans.minn = min( minn, sum + x.minn ); ans.sum = sum + x.sum; return ans; } }; info lazy[4 * MAX_N]; void propag( int v, int l, int r ) { if ( l != r ) { lazy[v * 2 + 1] = lazy[v * 2 + 1] + lazy[v]; lazy[v * 2 + 2] = lazy[v * 2 + 2] + lazy[v]; lazy[v] = { 0, 0 }; } } void update( int v, int l, int r, int lu, int ru, int x ) { propag( v, l, r ); if ( l > ru || r < lu ) return; if ( lu <= l && r <= ru ) { info add = { x, min( x, 0LL ) }; lazy[v] = lazy[v] + add; propag( v, l, r ); return; } int mid = (l + r) / 2; update( v * 2 + 1, l, mid, lu, ru, x ); update( v * 2 + 2, mid + 1, r, lu, ru, x ); } long long query( int v, int l, int r, int p ) { propag( v, l, r ); if ( l == r ) return lazy[v].sum - lazy[v].minn; int mid = (l + r) / 2; if ( p <= mid ) return query( v * 2 + 1, l, mid, p ); return query( v * 2 + 2, mid + 1, r, p ); } } qs; signed main() { int n, m, q; cin >> n >> m >> q; while ( q-- ) { int type; cin >> type; if ( type == 1 ) { int l, r, c, k; cin >> l >> r >> c >> k; qs.update( 0, 1, n, l, r, k ); } else if ( type == 2 ) { int l, r, k; cin >> l >> r >> k; qs.update( 0, 1, n, l, r, -k ); } else { int p; long long x; cin >> p >> x; long long s = qs.query( 0, 1, n, p ); cout << (s >= x) << "\n"; } } return 0; }

Compilation message (stderr)

foodcourt.cpp: In member function 'void SegTree::update(int, int, int, int, int, int)':
foodcourt.cpp:38:41: error: no matching function for call to 'min(int&, long long int)'
   38 |             info add = { x, min( x, 0LL ) };
      |                                         ^
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 foodcourt.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
foodcourt.cpp:38:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |             info add = { x, min( x, 0LL ) };
      |                                         ^
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 foodcourt.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
foodcourt.cpp:38:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |             info add = { x, min( x, 0LL ) };
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from foodcourt.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
foodcourt.cpp:38:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |             info add = { x, min( x, 0LL ) };
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from foodcourt.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
foodcourt.cpp:38:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |             info add = { x, min( x, 0LL ) };
      |                                         ^