이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define int long long
#define F first
#define S second
#define pb push_back
#define in insert
#define mid (l+r)/2
#define endl "\n"
//#define pop pop_back
using namespace std ;
int n,x,tree[8000009],b[200009],res=0,dp[200009],c[200009];
int query(int node , int l , int r , int s , int e){
if(l>=s && r<=e) return tree[node];
else if(l>e || r<s) return 0;
return max(query(node*2,l,mid,s,e),query(node*2+1,mid+1,r,s,e));
}
void upd(int node , int l , int r , int id , int v){
if(l==r){
tree[node]=v;
return ;
}
else if(id<=mid) upd(node*2,l,mid,id,v);
else upd(node*2+1,mid+1,r,id,v);
tree[node]=max(tree[node*2],tree[node*2+1]);
return ;
}
int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cin>>n>>x;
vector<int> v;
for(int i=1;i<=n;i++){
cin>>b[i];
v.pb(b[i]);
}
sort(begin(v),end(v));v.resize(unique(v.begin(),v.end())-v.begin());
map<int,int> mp;int t=0;for(auto u : v) mp[u]=++t;
for(int i=1;i<=n;i++) b[i]=mp[b[i]];
for(int i=1;i<=n;i++){
dp[i]=1+query(1,0,n,0,b[i]-1);
res=max(res,dp[i]);
upd(1,0,n,b[i],dp[i]);
}
cout<<res;
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... |