이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, x; cin >> n >> x;
vector<long long> v(n+1, 0);
for(int i=1; i<=n; i++){
cin >> v[i];
}
vector<long long> lj;
lj.push_back(v[1]);
vector<int> elol(n+1, 0);
elol[1]=1;
for(int i=2; i<=n; i++){
int j = lower_bound(lj.begin(), lj.end(), v[i]) - lj.begin();
elol[i]=j+1;
if(j == lj.size()){
lj.push_back(0);
}
lj[j]=v[i];
}
lj.clear();
lj.push_back(-v[n]);
vector<int> hatul(n+2, 0);
if(v[n-1] < v[n]+x) hatul[n]=1;
for(int i=n-1; i>0; i--){
int j = lower_bound(lj.begin(), lj.end(), -v[i]) - lj.begin();
if(j == lj.size()){
lj.push_back(0);
}
lj[j]=-v[i];
hatul[i] = lower_bound(lj.begin(), lj.end(), -1*(v[i-1]-x)) - lj.begin();
}
for(int x : elol) cout << x << " ";
cout << endl;
for(int x : hatul) cout << x << " ";
cout << endl;
int maxi=0;
for(int i=0; i<=n; i++){
maxi=max(maxi, elol[i]+hatul[i+1]);
}
cout << maxi << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'int main()':
glo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | if(j == lj.size()){
| ~~^~~~~~~~~~~~
glo.cpp:30:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if(j == lj.size()){
| ~~^~~~~~~~~~~~
# | 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... |