CF1776H. Beppa and SwerChat
lxg_honoka · · 题解
CF1776H. Beppa and SwerChat
群聊按最近的上线时间显示人员,Beppa在 9:00 和 22:00各上线一次查看群人员,求这段时间内至少有几人上线一次
只需求出有多少人没有上线,即顺序仍符合上午的顺序
一个指针指向早序列的末尾,一个指针指向晚序列的末尾。如果
#include<bits./stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn], b[maxn];
int main ()
{
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= n; i++)
scanf("%d", &b[i]);
int tot = 0;
for (int x = n, y = n; x > 0; x--)
{
if (a[x] == b[y]) //一致,说明没上线
tot++, y--;
}
printf("%d\n", n - tot);
}
return 0;
}