AcWing 800. 数组元素的目标和
原题链接
简单
作者:
葱花鸡蛋
,
2020-03-28 17:56:38
,
所有人可见
,
阅读 366
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int m, n, ta;
cin >> m >> n >> ta;
vector<int>buffa(m);
vector<int>buffb(n);
for (int i = 0; i < m; ++i) cin >> buffa[i];
for (int j = 0; j < n; ++j) cin >> buffb[j];
int l = 0, r = n - 1;
bool flag = false;
while(buffa[l] + buffb[r] != ta) {
while (buffa[l] + buffb[r] > ta) r--;
while (buffa[l] + buffb[r] < ta) l++;
}
cout << l << " " << r;
return 0;
}