Submission #1305524

#TimeUsernameProblemLanguageResultExecution timeMemory
1305524liangjeremyGlobal Warming (CEOI18_glo)C++20
15 / 100
2096 ms10320 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; } }; int solve(vector<int>v){ int n=v.size()-1; vector<int>x; for(int i=1; i<=n; i++){ x.push_back(v[i]); } sort(x.begin(),x.end()); x.erase(unique(x.begin(),x.end()),x.end()); for(int i=1; i<=n; i++){ v[i]=lower_bound(x.begin(),x.end(),v[i])-x.begin()+1; } BIT bit(n+1); vector<int>dp(n+1); for(int i=1; i<=n; i++){ dp[i]=bit.query(v[i]-1)+1; bit.update(v[i],dp[i]); } return bit.query(n); } 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); for(int i=1; i<=n; i++){ cin>>a[i]; } int ans=0; for(int delta=-x; delta<=x; delta++){ for(int i=1; i<=n; i++){ vector<int>na=a; for(int j=i; j<=n; j++){ na[j]+=delta; ans=max(ans,solve(na)); } } } cout<<ans<<'\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...