

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
*Code Pascal:
var n,m,d:int64;
i:longint;
a,b:array[0..10000000]of int64;
procedure qsort(l,r:int64);
Var i,j,x,w:int64;
Begin
x:=A[(l+r) div 2];
i:=l;j:=r;
Repeat
While(a[i]<x) do i:=i+1;
While (x<a[j]) do j:=j-1;
If i<=j then
Begin
w:=a[i];a[i]:=a[j];a[j]:=w;
i:=i+1;j:=j-1;
End;
until i>j;
If l<j then qsort(l,j);
If i<r then qsort(i,r);
End;
procedure qsort1(l,r:int64);
Var i,j,x,w:int64;
Begin
x:=b[(l+r) div 2];
i:=l;j:=r;
Repeat
While(b[i]<x) do i:=i+1;
While (x<b[j]) do j:=j-1;
If i<=j then
Begin
w:=b[i];b[i]:=b[j];b[j]:=w;
i:=i+1;j:=j-1;
End;
until i>j;
If l<j then qsort1(l,j);
If i<r then qsort1(i,r);
End;
begin
read(m,n);
for i:=1 to m do read(a[i]);
for i:=1 to n do read(b[i]);
qsort(1,m);
qsort1(1,n);
for i:=1 to m do
if a[i]<=b[i] then begin d:=0; break;
end
else d:=1;
if d=1 then write('YES')
else write('NO');
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
c++
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
int boys[m], girls[n];
for (int i = 0; i < m; i++) {
cin >> boys[i];
}
for (int i = 0; i < n; i++) {
cin >> girls[i];
}
sort(boys, boys + m);
sort(girls, girls + n);
int i = 0, j = 0;
while (i < m && j < n) {
if (boys[i] > girls[j]) {
i++;
j++;
} else {
i++;
}
}
if (j == n) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin