이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define int ll
const ll mod = 1e9 + 7;
main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int n , x;cin >> n >> x;
vector<int> a(n) , s(n);
vector<int> dp(n , LLONG_MAX);
int ans = 0;
for(int i = 0;i < n;i ++){
cin >> a[i];
int w = lower_bound(all(dp) , a[i]) - dp.begin();
dp[w] = a[i];
s[i] = w + 1;
ans = max(ans , s[i]);
}
for(int i = 0;i < n;i ++) dp[i] = LLONG_MAX;
for(int i = n - 1;i > -1;i --){
int j = lower_bound(all(dp) , x - a[i]) - dp.begin();
int y = lower_bound(all(dp) , -a[i]) - dp.begin();
//cout << s[i] << " " << j << endl;
ans = max(ans , s[i] + j);
dp[y] = -a[i];
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
# | 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... |