fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <algorithm>
  5. #include <set>
  6. using namespace std;
  7.  
  8. int cover(int l1, int r1, int l2, int r2){
  9. return max(min(r1, r2) - max(l1, l2) + 1, 0);
  10. }
  11.  
  12. int main() {
  13. cin.tie(0)->sync_with_stdio(0);
  14. int n, m, q, sa = 0, sb = 0, x;
  15. cin >> n >> m >> q;
  16. vector <int> a(n);
  17. vector <int> b(m);
  18. set <int> s;
  19. for(int i = 0; i < n; i++){
  20. cin >> a[i];
  21. sa += a[i];
  22. }
  23. for(int i = 0; i < m; i++){
  24. cin >> b[i];
  25. sb += b[i];
  26. }
  27. for(int i = 0; i < n; i++){
  28. for(int j = 0; j < m; j++){
  29. s.insert(sa * sb - a[i] * sb - b[j] * sa + a[i] * b[j]);
  30. }
  31. }
  32. while(q--){
  33. cin >> x;
  34. if(s.count(x))cout << "Yes\n";
  35. else cout << "No\n";
  36. }
  37. }
Success #stdin #stdout 0s 5264KB
stdin
3 3 6
-2 3 -3
-2 2 -1
-1
1
-2
2
-3
3
stdout
No
Yes
No
No
Yes
No