Submission #730507

#TimeUsernameProblemLanguageResultExecution timeMemory
730507nguyentunglamA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; const int N = 1e5 + 10; long long a[N]; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // long long Skim(int i) { if (a[i]) return a[i]; return a[i] = skim(i); } void solve(int n, int k, long long A, int s) { // // TODO implement this function int l = 1, r = n; long long v = 0; int p = n + 1; while (l <= r) { int mid = l + r >> 1; long long tmp = Skim(mid); if (tmp >= A) { v = tmp; p = mid; r = mid - 1; } else l = mid + 1; } for(int i = 1; i <= k - 1; i++) v += Skim(i); vector<int> ret; if (p <= n && k - 1 < p && v <= A * 2) { for(int i = 1; i <= k - 1; i++) ret.push_back(i); ret.push_back(p); answer(ret); } long long cur = 0; for(int i = k; i >= 1; i--) { ret.push_back(i); cur += Skim(i); cur = min(cur, 2e18); } if (cur > A * 2) impossible(); else if (cur >= A) answer(ret); else { --p; vector<int> add; bool ok = 0; while (p > k) { cur = cur - Skim(ret.back()) + Skim(p); ret.pop_back(); add.push_back(p); p--; if (cur >= A) { for(int &j : add) ret.push_back(j); answer(ret); ok = 1; return; } } if (!ok) impossible(); } }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:28:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |         int mid = l + r >> 1;
      |                   ~~^~~
books.cpp:51:28: error: no matching function for call to 'min(long long int&, double)'
   51 |         cur = min(cur, 2e18);
      |                            ^
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 books.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:
books.cpp:51:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   51 |         cur = min(cur, 2e18);
      |                            ^
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 books.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:
books.cpp:51:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   51 |         cur = min(cur, 2e18);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.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:
books.cpp:51:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |         cur = min(cur, 2e18);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from books.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:
books.cpp:51:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |         cur = min(cur, 2e18);
      |                            ^