使用单个unordered_map存储target值与第一个数组的差即可
#include <iostream>
#include <unordered_map>
using namespace std;
const int N = 1e5 + 10;
int n, m, x, t;
int main()
{
cin >> n >> m >> x;
unordered_map<int, int> record;
for (int i = 0; i < n; ++i) {
cin >> t;
record[x - t] = i;
}
for (int j = 0; j < m; ++j)
{
cin >> t;
if (record.count(t))
{
cout << record[t] << " " << j << endl;
break;
}
}
return 0;
}