8922022-01-25 11:35:34kidesoRobotokcpp14Accepted 50/50101ms26976 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <set>

using namespace std;

ifstream f("be.txt");

vector <vector <int> > x;
int N, M, K;

int main()
{
	cin >> N >> M >> K;
	x.resize(M+1);
	for (int i = 1; i <= K; ++i) {
		int a, b;
		cin >> a >> b;
		x[b].push_back(a);
	}

	for (auto& e : x) sort(e.begin(), e.end());

	multiset <int> y;
	int k = 0, i = 1;
	for (int i = 1; i <= M; ++i) {
		for (auto e : x[i]) {
			auto it = y.lower_bound(e + 1);
			if (!y.empty() && it != y.begin()) y.erase(--it);
			y.insert(e);
		}
	}

	cout << y.size() << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1744 KiB
2Accepted0/0101ms10904 KiB
3Accepted2/21ms2772 KiB
4Accepted2/21ms2780 KiB
5Accepted2/21ms2780 KiB
6Accepted2/23ms2816 KiB
7Accepted2/23ms2848 KiB
8Accepted2/22ms2888 KiB
9Accepted2/22ms2904 KiB
10Accepted2/22ms2928 KiB
11Accepted2/210ms3260 KiB
12Accepted2/234ms4032 KiB
13Accepted2/22ms3720 KiB
14Accepted2/293ms16436 KiB
15Accepted2/290ms18496 KiB
16Accepted2/293ms17196 KiB
17Accepted4/489ms23556 KiB
18Accepted6/689ms21432 KiB
19Accepted6/6100ms25840 KiB
20Accepted6/6100ms26976 KiB