fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N,K;
  6. bool answer = false;
  7. cin >> N >> K;
  8. vector<int>P(N),Q(N);
  9. for(int i=0; i<N; i++){
  10. cin >> P[i];
  11. }
  12. for(int i=0; i<N; i++){
  13. cin >> Q[i];
  14. }
  15.  
  16. for(int i=0; i<N; i++){
  17. for(int j=0; j<N; j++){
  18. if(P[i]==K-Q[j]){
  19. answer = true;
  20. }
  21. }
  22. }
  23.  
  24. if(answer){
  25. cout << "Yes";
  26. }else{
  27. cout << "No";
  28. }
  29. // your code goes here
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5332KB
stdin
5 53
10 20 30 40 50
1 2 3 4 5
stdout
Yes