| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1358701 | lyra_g13 | 송신탑 (IOI22_towers) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include "towers.h"
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int n;
vector<int> h;
void init(int N, vector<int> H) {
n = N;
h = H;
};
int max_towers(int l, int r, int d) {
int ans = 1;
vector<ll> dp(n, 1);
for (int i = l; i <= r; i++) {
dp[i] = 1;
ll mid = 0;
for (int j = i - 1; j >= l; j--) {
if (j + 1 < i)
mid = max(mid, h[j + 1]);
ll bound = max(h[j], h[i]) + d;
if (mid >= bound)
dp[i] = max(dp[i], dp[j] + 1);
}
ans = max(ans, dp[i]);
}
return ans;
};컴파일 시 표준 에러 (stderr) 메시지
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:21:18: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
21 | mid = max(mid, h[j + 1]);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
from towers.h:1,
from towers.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
towers.cpp:21:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
21 | mid = max(mid, h[j + 1]);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed:
towers.cpp:21:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
21 | mid = max(mid, h[j + 1]);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
from towers.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5795 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed:
towers.cpp:21:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
21 | mid = max(mid, h[j + 1]);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5805 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed:
towers.cpp:21:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
21 | mid = max(mid, h[j + 1]);
| ~~~^~~~~~~~~~~~~~~
towers.cpp:27:14: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
27 | ans = max(ans, dp[i]);
| ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
towers.cpp:27:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
27 | ans = max(ans, dp[i]);
| ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed:
towers.cpp:27:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
27 | ans = max(ans, dp[i]);
| ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5795 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed:
towers.cpp:27:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
27 | ans = max(ans, dp[i]);
| ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5805 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed:
towers.cpp:27:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
27 | ans = max(ans, dp[i]);
| ~~~^~~~~~~~~~~~