#include <iostream> #include <vector> #include <algorithm> using namespace std;
int main() { long long n, m, i, j, k; cin >> n >> m; vector < long long > plot, mesk;
for (i = 0; i < n; i++) for (j = 0; j < m; j++) { long long x; cin >> x; plot.push_back(x); } cin >> k; for (i = 0; i < k; i++) { long long x; cin >> x; mesk.push_back(x); } sort(plot.begin(), plot.end()); sort(mesk.begin(), mesk.end());
k = 0; i = plot.size() - 1; j = mesk.size() - 1; while (i * j > 0) { if (plot[i] >= mesk[j]) { k++; i--; j--; } else j--; } cout << k << endl; }
class Main { public static void main(String[] args) { ArrayList<Integer> a = new ArrayList();
/** * Заполнение */ for (int i = 0; i < 50; i++) a.add(i, new java.util.Random().nextInt(100));
/** * Пузырь */ for (int i = 0; i < 50; i++) for (int j = 0; j < 50-i-1; j++) if (a.get(j) > a.get(j+1)){ int b = a.get(j); a.set(j, j+1); a.set(j+1, b); }
for (int i = 0; i < 50; i++) System.out.print(a.get(i) + " "); System.out.println("\n---");
/** * Удаляем */ a.remove(0);
for (int i = 0; i < 50-1; i++) System.out.print(a.get(i) + " "); } }
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
long long n, m, i, j, k;
cin >> n >> m;
vector < long long > plot, mesk;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
{
long long x;
cin >> x;
plot.push_back(x);
}
cin >> k;
for (i = 0; i < k; i++)
{
long long x;
cin >> x;
mesk.push_back(x);
}
sort(plot.begin(), plot.end());
sort(mesk.begin(), mesk.end());
k = 0;
i = plot.size() - 1;
j = mesk.size() - 1;
while (i * j > 0)
{
if (plot[i] >= mesk[j])
{
k++;
i--;
j--;
}
else
j--;
}
cout << k << endl;
}