Let'sPlayCurling(牛客思维)
#include <bits/stdc++.h>
using namespace std;
signed main(){
int t; cin >> t;
while(t--){
int n, m; cin >> n >> m;
map<int, int> mp;
for(int i = 1; i <= n; ++i){
int x; cin >> x; mp[x]++;
}
for(int i = 1; i <= m; ++i){
int x; cin >> x; mp[x] = -1;
}
int t = 0, maxv = INT_MIN;
for(auto &x : mp){
if(mp[x.first] == -1){
maxv = max(maxv, t);
t = 0;
}else t += mp[x.first];
}
maxv = max(maxv, t);
if(maxv) cout << maxv << endl;
else cout << "Impossible" << endl;
}
return 0;
}

浙公网安备 33010602011771号