Submission #58324

#TimeUsernameProblemLanguageResultExecution timeMemory
58324PeppaPig쌀 창고 (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; const int N = 5e3 + 5; long long sum[N]; int besthub(int R, int L, int X[], long long B) { for(int i = 1; i <= R; i++) sum[i] = sum[i - 1] + X[i - 1]; int res = 1; int l = 2, r = R; while(l <= r) { int mid = (l + r) >> 1; int m = mid >> 1; long long ret = LLONG_MAX; for(int i = 1; i <= R - mid + 1; i++) { if(mid == 2) ret = min(ret, X[i + 1] - X[i]); else { long long t = sum[i + mid - 1] - sum[i + m] - sum[i + m - 1] + sum[i - 1]; if(mid & 1) ret = min(ret, t); else ret = min(ret, t + sum[i + m]); } } if(ret <= B) res = mid, l = mid + 1; else r = mid - 1; } return res; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:20:47: error: no matching function for call to 'min(long long int&, int)'
    if(mid == 2) ret = min(ret, X[i + 1] - X[i]);
                                               ^
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 ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    if(mid == 2) ret = min(ret, X[i + 1] - X[i]);
                                               ^
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 ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    if(mid == 2) ret = min(ret, X[i + 1] - X[i]);
                                               ^
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 ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    if(mid == 2) ret = min(ret, X[i + 1] - X[i]);
                                               ^
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 ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ricehub.cpp:20:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    if(mid == 2) ret = min(ret, X[i + 1] - X[i]);
                                               ^