Guest User

Untitled

a guest
Feb 29th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int N,K;
  6.     int A[N],B[N];
  7.     scanf("%d%d",&N,&K);
  8.     for (int i=0; i<N; i++){
  9.         scanf("%d",&A[i]);
  10.     }
  11.     for (int i=0; i<N; i++){
  12.         scanf("%d",&B[i]);
  13.     }
  14.     sort(A,A+N); reverse(A,A+N);
  15.     sort(B,B+N); reverse(B,B+N);
  16.     if (A[0] > B[0]){
  17.         cout << A[0] + B[K-1] << "\n";
  18.     }
  19.     else{
  20.         cout << B[0] + A[K-1] << "\n";
  21.     }
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment