Submission #832356

#TimeUsernameProblemLanguageResultExecution timeMemory
832356vjudge1Exam (eJOI20_exam)C++14
12 / 100
37 ms1712 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define rep(i,n,N) for(int i = n; i<=N; ++i) #define rap(i,n,N) for(int i = n; i>=N; --i) #define For(i,n,N) for(int i = n; i< N; ++i) #define endl '\n' #define pb push_back #define all(x) x.begin(),x.end() #define mems(x,y) memset(x,y,sizeof x) #define ari(x) array<int,x> #define pll pair<ll,ll> #define pii pair<int,int> #define fi first #define se second const int MAX = 1e5 + 5; mt19937 rng(time(NULL)); int n,x[MAX],y[MAX],cnt,opt[MAX]; vector<int> v; bool vis[MAX],gg; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; rep(i,1,n)cin>>x[i], v.pb(x[i]); sort(all(v)); v.erase(unique(all(v)), v.end()); rep(i,1,n)x[i] = upper_bound(all(v), x[i]) - v.begin(); auto it = v.begin(); rep(i,1,n){ cin>>y[i]; it = lower_bound(all(v), y[i]); y[i] = it==v.end() || *it!=y[i] ? 0 : it-v.begin()+1; } // cout<<"____\n"; // rep(i,1,n)cout<<x[i]<<" "; cout<<endl; // rep(i,1,n)cout<<y[i]<<" "; cout<<endl; x[0] = x[n+1] = v.size()+1; bool tc2 = 1; rep(i,2,n)if(y[i]!=y[i-1])tc2 = 0; if(tc2){ gg = 0; rep(i,1,n){ if(x[i]==y[i])gg = 1; else if(x[i]>y[i])gg = 0; vis[i]|= gg; } gg = 0; rap(i,n,1){ if(x[i]==y[i])gg = 1; else if(x[i]>y[i])gg = 0; vis[i]|= gg; cnt+= vis[i]; } cout<<cnt<<endl; return 0; } bool tc3 = 1; rep(i,1,n)if(x[i]!=i)tc3 = 0; if(tc3){ int mx; rep(i,1,n){ mx = cnt = 0; rap(j,i,1){ if(x[i]==y[j])++cnt; mx = max(mx, cnt+opt[j-1]); } opt[i] = mx; } cout<<opt[n]<<endl; return 0; } return 0; }
#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...