이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define v vector
#define int long long
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define ff first
#define ss second
#define inp_v(vec) for (auto &i : vec) cin >> i;
#define prt_v(vec) for (auto i : vec) cout << i << endl;
#define MS(x) memset(x, 0, sizeof(x))
#define gcd(a,b) __gcd(a, b);
#define lcm(a,b) (a*(b/gcd(a,b)))
bool chmin(int &a, int b){return b<a?a=b, true:false;}
bool chmax(int &a, int b){return b>a?a=b, true:false;}
const int maxn=2e5+5;
int dp[maxn], A[maxn];
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int N, x;cin>>N>>x;
for(int i=1;i<=N;i++)cin>>A[i];
if(!x){
multiset<pair<int, int>>st;
dp[N]=1;
st.insert({A[N], 1});
int ans=1;
for(int i=N-1;i>=1;i--){
auto it=st.upper_bound({A[i], 0});
if(it==st.end())dp[i]=1;
else{
dp[i]=(*it).second+1;
}
ans=max(ans, dp[i]);
auto lb=st.lower_bound({A[i], 0});
if(lb!=st.end())st.erase(lb);
st.insert({A[i], dp[i]});
}
cout<<ans<<endl;
}
return 0;
}
# | 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... |