`平均时间复杂度O(nlogm)的解决方案
include [HTML_REMOVED]
using namespace std;
const int N = 100010;
int n, m, x;
int A[N], B[N];
int main()
{
int flag = 0;
cin >> n >> m >> x;
for (int i = 0; i < n; i ) cin >> A[i];
for (int i = 0; i < m; i ) cin >> B[i];
for (int i = n - 1; i >= 0; i -- )
{
if (flag == 1) break;
if (A[i] + B[0] == x)
{
cout << i << " " << 0;
break;
}
if (A[i] + B[0] > x) continue;
//二分找答案
int l = 0, r = m - 1;
while (l <= r)
{
int mid = l + r >> 1;
if(A[i] + B[mid] == x)
{
cout << i << " " << mid;
flag = 1;
break;
}
if(A[i] + B[mid] > x) r = mid - 1;
else l = mid + 1;
}
}
return 0;
}`