二分法
复杂度: $O(nlogn)$
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e6+50;
int a[N], b[N];
int n, m, k;
int main(){
cin >> n >> m >> k;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < m; i++) cin >> b[i];
for(int i = 0; i < n; i++){
int t = k - a[i];
if(binary_search(b, b+m, t)){
int index = lower_bound(b, b+m, t) - b;
cout << i << " " << index << endl;
}
}
return 0;
}