| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1223453 | mariamp1 | Just Long Neckties (JOI20_ho_t1) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 2000005;
int b[MAXN], ans[MAXN], prefix[MAXN], suffix[MAXN];
pair<long long, int> a[MAXN];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n + 1; ++i) {
cin >> a[i].first;
a[i].second = i;
}
for (int i = 1; i <= n; ++i) {
cin >> b[i];
}
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
for (int i = 1; i <= n; ++i) {
prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
}
for (int i = n + 1; i >= 1; --i) {
suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
}
for (int i = 1; i <= n + 1; ++i) {
int idx = a[i].second;
ans[idx] = max(prefix[i - 1], suffix[i + 1]);
}
for (int i = 1; i <= n + 1; ++i) {
cout << ans[i] << " ";
}
cout << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:29:24: error: no matching function for call to 'max(int&, long long int)'
29 | prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:29:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
29 | prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:29:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
29 | prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:29:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:29:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | prefix[i] = max(prefix[i - 1], a[i].first - b[i]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:33:24: error: no matching function for call to 'max(int&, long long int)'
33 | suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:33:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
33 | suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
from /usr/include/c++/11/ios:40,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:33:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
33 | suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:33:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
33 | suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
from /usr/include/c++/11/bits/locale_classes.h:40,
from /usr/include/c++/11/bits/ios_base.h:41,
from /usr/include/c++/11/ios:42,
from /usr/include/c++/11/ostream:38,
from /usr/include/c++/11/iostream:39,
from ho_t1.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:
ho_t1.cpp:33:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
33 | suffix[i] = max(suffix[i + 1], a[i].first - b[i - 1]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~