Pagini recente » Cod sursa (job #2705684) | Cod sursa (job #694062) | Cod sursa (job #1117446) | Cod sursa (job #2128719) | Cod sursa (job #2924229)
#include <bits/stdc++.h>
using namespace std;
int t,n,d[1005];
int v[1005];
pair<int,int>a[1005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
for (int q = 1; q <= t; q++)
{
for (int i = 1; i <= 1000; i++)
d[i] = 1e9;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].first;
for (int i = 1; i <= n; i++)
cin >> a[i].second;
sort(a + 1,a + n + 1);
for (int i = 1; i <= n; i++)
v[i] = a[i].second;
for (int i = 1; i <= n; i++)
{
int st = 0,pas = 1 << 9;
while (pas != 0)
{
if (st + pas <= n and d[st + pas] < v[i])
st += pas;
pas /= 2;
}
st++;
d[st] = v[i];
}
int ans = 0;
for (int i = 1; i <= n; i++)
if (d[i] != 1e9)
ans = i;
cout << ans << '\n';
}
return 0;
}