Submission #1170237

#TimeUsernameProblemLanguageResultExecution timeMemory
1170237uranhishigBouquet (EGOI24_bouquet)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(a) (a).begin(),(a).end() #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) const int mx = 8e5 + 9; bool b1 = true; bool b2 = true; bool b4 = true; int s[mx]; int dp[mx]; vector<int>q[mx]; void update(int i, int L, int R, int k, int v) { if (L == R) { s[i] = v; return; } int M = (L + R) / 2; int x = 2 * i + 1, y = x + 1; if (k <= M) update(x, L, M, k, v); else update(y, M + 1, R, k, v); s[i] = max(s[x], s[y]); return; } int query(int i, int L, int R, int l, int r) { if (L == l && r == R) { return s[i]; } int M = (L + R) / 2; int x = 2 * i + 1, y = x + 1; if (r <= M) return query(x, L, M, l, r); else if (M + 1 <= l) return query(y, M + 1, R, l, r); else return max(query(x, L, M, l, M) , query(y, M + 1, R, M + 1, r)); } signed main() { int n; cin >> n; vector<int> l(n); vector<int> r(n); for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; if (r[i] != 0) { b2 = false; } } int ans = 0; for (int i = 1; i <= n; i++) { int ll = i - l[i]; int rr = i + r[i]; dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1; ans = max(ans, dp[i]); if (rr <= n) q[rr].push_back(i); for (int j : q[i]) { update(0, 0, n, j, dp[j]); } } cout << ans << endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:59:46: error: no matching function for call to 'max(int, long long int)'
   59 |                 dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1;
      |                                           ~~~^~~~~~~~~~~
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 Main.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:
Main.cpp:59:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   59 |                 dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1;
      |                                           ~~~^~~~~~~~~~~
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 Main.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:
Main.cpp:59:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   59 |                 dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1;
      |                                           ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Main.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:
Main.cpp:59:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |                 dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1;
      |                                           ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from Main.cpp:1:
/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:
Main.cpp:59:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |                 dp[i] = query(0, 0, n, 0, max(0, ll - 1)) + 1;
      |                                           ~~~^~~~~~~~~~~