# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1171747 | pawelkawa | A Plus B (IOI23_aplusb) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int main () {
unsigned int n;
cin >> n;
vector <int> A(n), B(n), C;
for (int i = 0; i<n; i++) {
cin >> A[i];
}
for (int i = 0; i<n; i++) {
cin >>B[i];
}
if (n==1) {
cout << A[0]+B[0] << endl;
return 0;
}
int i = 0, j = 0;
while (C.size() < n) {
C.push_back(A[i]+B[j]);
if (i == n-1)
j++;
else if (j == n-1)
i++;
else {
if (A[i]+B[j+1] < A[i+1] + B[j])
j++;
else
i++;
}
// cout << i << ' ' << j << endl;
}
for (auto x : C)
cout << x << ' ';
cout << '\n';
return 0;
}