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