2026.9.13 NOIP 模拟赛复盘
2026.9.13 NOIP 模拟赛复盘
[TOC] 题 | 得分 | 总结 | | --------- | ---- | -------------------------------- | | T1 ⽐赛 | 30 | 前面想了好久,最后打了20分暴力 | | T2 序列 | 5 | 在看完第一题后想了第二题,但没有太多思路,把dp想复杂了 | | T3 重排 | 20 | 打了暴力 | | T4 排序 | 0 | 在最后还是想看一下T1 T2 有没有做出来的可能,导致没有看 | | 总分 | 55 | 在遇到难题时心态不好,导致整体出现了一些问题 |
T818443 序列
设数字 x 在 t 中第一次出现的位置为
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e5+5;
int dp[maxn];
vector<int>V[maxn];
int a[maxn];
int b[maxn];
int n,m;
int lst[maxn];
int fst[maxn];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
// freopen("seq.in","r",stdin);
// freopen("seq.out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++){
cin>>b[i];
lst[b[i]]=i;
if(fst[b[i]]==0)fst[b[i]]=i;
}
int ans=0;
dp[0]=1e9;
for(int i=1;i<=n;i++){
if(lst[a[i]]==0)continue;
int tmp=upper_bound(dp+1,dp+1+n,lst[a[i]],greater<int>() )-dp;
dp[tmp]=max(dp[tmp],fst[a[i]]);
ans=max(ans,tmp);
}
for(int i=1;i<=n;i++){
if(lst[a[i]]==0)ans++;
}
cout<<ans;
}