Advertisement
Trawka011

Untitled

Oct 5th, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n, b;
  6.     cin >> n;
  7.     int* arra = new int[n];
  8.     for (int i = 0; i < n; i++) {
  9.         cin >> arra[i];
  10.     }
  11.     cin >> b;
  12.     int* arrb = new int[b];
  13.     for (int i = 0; i < b; i++) {
  14.         cin >> arrb[i];
  15.     }
  16.     int j = 0;
  17.     for (int i = 0; i < n; j++) {
  18.         if (arra[i] + arrb[j] == 10000) {
  19.             cout << "YES";
  20.             return 0;
  21.         }
  22.         if (j == b - 1) {
  23.             i++;
  24.             j = 0;
  25.         }
  26.     }
  27.     cout << "NO";
  28.     delete[] arra;
  29.     delete[] arrb;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement