Let'sPlayCurling(牛客思维)

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;
}
posted @ 2025-03-19 13:46  awei040519  阅读(13)  评论(0)    收藏  举报