Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int N,K;
- int A[N],B[N];
- scanf("%d%d",&N,&K);
- for (int i=0; i<N; i++){
- scanf("%d",&A[i]);
- }
- for (int i=0; i<N; i++){
- scanf("%d",&B[i]);
- }
- sort(A,A+N); reverse(A,A+N);
- sort(B,B+N); reverse(B,B+N);
- if (A[0] > B[0]){
- cout << A[0] + B[K-1] << "\n";
- }
- else{
- cout << B[0] + A[K-1] << "\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment