0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 14:58:48 +00:00

800. 数组元素的目标和

https://www.acwing.com/problem/content/submission/code_detail/10689264/
This commit is contained in:
Baoshuo Ren 2022-02-08 10:52:04 +08:00
parent 7ce65aead5
commit f5a875fab4
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
AcWing/800/800.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
using std::cin;
using std::cout;
#define endl '\n'
const int N = 100005;
int n, m, x, a[N], b[N];
int main() {
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 = 0, j = m - 1; i < n; i++) {
while (a[i] + b[j] > x) j--;
if (a[i] + b[j] == x) {
cout << i << ' ' << j << endl;
exit(0);
}
}
return 0;
}