이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, x, idx, arr[200010], pre[200010], ans;
vector<int> dp;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> x;
for(int i=1; i<=n; i++) {
cin >> arr[i];
idx = lower_bound(dp.begin(), dp.end(), arr[i]) - dp.begin();
if(idx == dp.size()) dp.push_back(arr[i]);
else dp[idx] = arr[i];
pre[i] = idx+1;
ans = max(ans, pre[i]);
}
dp.clear();
for(int i=n; i>0; i--) {
idx = lower_bound(dp.begin(), dp.end(), -arr[i]+x) - dp.begin();
ans = max(ans, pre[i] + idx);
idx = lower_bound(dp.begin(), dp.end(), -arr[i]) - dp.begin();
if(idx == dp.size()) dp.push_back(-arr[i]);
else dp[idx] = -arr[i];
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'int main()':
glo.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | if(idx == dp.size()) dp.push_back(arr[i]);
| ~~~~^~~~~~~~~~~~
glo.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | if(idx == dp.size()) dp.push_back(-arr[i]);
| ~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |