# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
422610 | snasibov05 | Global Warming (CEOI18_glo) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
#define oo 1000000000
int main() {
int n, x; cin >> n >> x;
vector<int> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
}
int sz = 1;
vector<int> dp(n);
vector<int> c(n+1, oo);
c[0] = 0;
c[1] = v[0];
dp[0] = 1;
for (int i = 1; i < n; ++i) {
if (v[i] < c[1]) c[1] = v[i], dp[i] = 1;
else if (v[i] > c[sz]) c[sz+1] = v[i], dp[i] = ++sz;
else {
int k = lower_bound(c.begin(), c.end(), v[i]) - c.begin();
c[k] = v[i];
dp[i] = k;
}
}
int ans = dp[n-1];
c.assign(n+1, 0);
c[0] = oo;
c[1] = v[n-1] + x;
dp[n-1] = 1;
sz = 1;
for (int i = n-2; i >= 0; --i){
if (v[i] > c[1]) ans = max(ans, dp[i]);
else if (v[i] < c[sz]) ans = max(ans, dp[i] + sz);
else{
int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin();
ans = max(ans, dp[i] + k - 1);
}
if (v[i] + x > c[1]) c[1] = v[i] + x;
else if (v[i] + x < c[sz]) c[sz+1] = v[i] + x, sz++;
else{
int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin();
k = n - k;
c[k] = v[i] + x;
}
}
cout << ans << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'int main()': glo.cpp:43:23: error: no match for 'operator-' (operand types are 'int' and 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >') 43 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin(); | ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > > In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)' 500 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: glo.cpp:43:63: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 43 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1533:5: note: candidate: 'template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)' 1533 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1533:5: note: template argument deduction/substitution failed: glo.cpp:43:63: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 43 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1164:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 1164 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1164:5: note: template argument deduction/substitution failed: glo.cpp:43:63: note: mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'int' 43 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1177:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 1177 | operator-(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1177:5: note: template argument deduction/substitution failed: glo.cpp:43:63: note: mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'int' 43 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i]) + c.rbegin(); | ^ glo.cpp:50:23: error: no match for 'operator-' (operand types are 'int' and 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >') 50 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin(); | ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > > In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)' 500 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: glo.cpp:50:67: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 50 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1533:5: note: candidate: 'template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)' 1533 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1533:5: note: template argument deduction/substitution failed: glo.cpp:50:67: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 50 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1164:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 1164 | operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1164:5: note: template argument deduction/substitution failed: glo.cpp:50:67: note: mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'int' 50 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin(); | ^ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/char_traits.h:39, from /usr/include/c++/10/ios:40, from /usr/include/c++/10/ostream:38, from /usr/include/c++/10/iostream:39, from glo.cpp:1: /usr/include/c++/10/bits/stl_iterator.h:1177:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 1177 | operator-(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1177:5: note: template argument deduction/substitution failed: glo.cpp:50:67: note: mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'int' 50 | int k = n - lower_bound(c.rbegin(), c.rend(), v[i] + x) + c.rbegin(); | ^