Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 1;
int n, m, k, a[N], b[N];
int main() {
scanf("%d %d %d", &n ,&m, &k);
for(int i = 0; i < n; ++i)
scanf("%d", a + i);
for(int i = 0; i < m; ++i)
scanf("%d", b + i);
sort(a, a + n);
reverse(a, a + n);
sort(b, b + m);
reverse(b, b + m);
for(int i = 0; i < min(n, m); ++i)
if(a[i] > b[i]) {
puts("YES");
return 0;
}
if(n > m)
puts("YES");
else
puts("NO");
return 0;
}
Copy The Code &
Try With Live Editor
Input
3 3 3
2 2 2
1 1 3
2 2 2
1 1 3
Output
YES
Demonstration
Codeforces Solution-Fish Weight-Solution in C, C++, Java, Python