이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
/**/
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
typedef std::string str;
/*typedef __int128 vll;
typedef unsigned __int128 uvll;*/
#define llll std::pair<ll , ll>
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e15 + 7;
const ll ous = 1e5 + 7;
const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1};
ll n , m;std::vector<ll> ar , ra;
std::vector<ll> lis , lde;
std::set<llll> st;
ll crlis = 0 , crlde = 0;
ll addlis(ll val){
ll l = 0 , r = crlis;
while(r > l){
ll md = (l + r + 1)/2;
if(lis[md] > val){
r = md - 1;
}
else{
l = md;
}
}
if(lis[0] == -1 || lis[0] >= val){
lis[0] = val;
return 1;
}
crlis = std::max(crlis , l + 1);
lis[l + 1] = val;
return l+2;
}
ll addlde(ll val){
ll l = 0 , r = crlde;
while(r > l){
ll md = (l + r + 1)/2;
if(lde[md] > val){
l = md;
}
else{
r = md - 1;
}
}
if(lde[0] == -1 || lde[0] <= val){
lde[0] = val;
return 1;
}
crlde = std::max(crlde , l + 1);
lde[l + 1] = val;
return l + 2;
}
ll check(ll val){
ll l = 0 , r = crlde;
while(r > l){
ll md = (l + r + 1)/2;
if(lde[md] > val){
l = md;
}
else{
r = md - 1;
}
}
if(lde[0] == -1 || lde[0] <= val){
return 0;
}
return l+1;
}
void solve(){
std::cin >> n >> m;
std::vector<ll> mem(n , 0);
ar.resize(n , -1);
ra.resize(n , -1);
lde.resize(n , -1);
lis.resize(n , -1);
ll ans = 0;
for(ll i = 0;n>i;i++){
ll x;std::cin >> x;
ar[i] = x;
mem[i] = addlis(x);
ans = std::max(ans , mem[i]);
}
/*for(ll i = n-1;0<=i;i--){
ll y = addlde(ar[i]);
std::cout << y << "\n";
for(ll i =0;crlde>=i;i++){
std::cout << lde[i] << " ";
}
std::cout << "\n";
ans = std::max(ans , mem[i]);
}
std::cout << "\n";
std::cout << ans << "\n";*/
for(ll i = n-1;0<=i;i--){
ll y = check(ar[i]);
ans = std::max(ans , mem[i] + y);
addlde(ar[i] + m);
}
//std::cout << "\n";
std::cout << ans << "\n";
return;/**/
}
signed main(){
ll t=1;
//std::cin >> t;
ll o = 1;
while(t--){
//cout << "Case " << o++ << ":\n";
solve();
}
return 0;
}/**/
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp:5:78: warning: "/*" within comment [-Wcomment]
5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
|
glo.cpp: In function 'int main()':
glo.cpp:120:8: warning: unused variable 'o' [-Wunused-variable]
120 | ll o = 1;
| ^
# | 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... |