제출 #1305518

#제출 시각아이디문제언어결과실행 시간메모리
1305518liangjeremyGlobal Warming (CEOI18_glo)C++20
10 / 100
58 ms6780 KiB
#include<bits/stdc++.h> #include<bits/extc++.h> #define fi first #define se second #define int long long using namespace std; //using namespace __gnu_pbds; using db=double; using ll=int64_t; using sll=__int128; using lb=long double; mt19937 rng(random_device{}()); struct BIT{ vector<int>bits; BIT(int n){ bits.resize(n+20); } void update(int index, int delta){ while(index<bits.size()){ bits[index]=max(bits[index],delta); index+=index&-index; } } int query(int index){ int ans=0; while(index>0){ ans=max(ans,bits[index]); index-=index&-index; } return ans; } }; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,x; cin>>n>>x; vector<int>a(n+1); vector<int>v; for(int i=1; i<=n; i++){ cin>>a[i]; v.push_back(a[i]); } sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); for(int i=1; i<=n; i++){ a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1; } vector<int>dp(n+1); BIT bit(n); for(int i=1; i<=n; i++){ dp[i]=bit.query(a[i]-1)+1; bit.update(a[i],dp[i]); } cout<<bit.query(n); } /* Overhead the albatross hangs motionless upon the air And deep beneath the rolling waves in labyrinths of coral caves The echo of a distant time comes willowing across the sand And everything is green and submarine And no one showed us to the land And no one knows the wheres or whys But something stirs and something tries And starts to climb towards the light */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...