702021-01-09 22:38:39Babják PéterRobotokcpp14Accepted 50/5039ms13736 KiB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct d
{
	int f,s;	
};
struct cmp
{
	bool operator()(const d &a, const d &b)
	{
		if(a.s==b.s)
		{
			return a.f<b.f;
		}
		return a.s<b.s;
	}	
};
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    d r[k];
    for(int i=0;i<k;i++)
    {
    	cin>>r[i].f>>r[i].s;
	}
	sort(r,r+k,cmp());
	vector<int>ans;
	ans.push_back(r[0].f);
	for(int i=1;i<k;i++)
	{
		vector<int>::iterator up;
		up=upper_bound(ans.begin(),ans.end(),r[i].f,greater<int>());
		int z=up-ans.begin();
		if(ans[z-1]==r[i].f)
		{
			continue;		
		}
		if(up==ans.end())
		{
			ans.push_back(r[i].f);
		}
		else
		{
			ans[z]=r[i].f;
		}
	}
	cout<<ans.size()<<endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1756 KiB
2Accepted0/028ms4052 KiB
3Accepted2/21ms2776 KiB
4Accepted2/21ms2804 KiB
5Accepted2/21ms2808 KiB
6Accepted2/23ms2828 KiB
7Accepted2/22ms2856 KiB
8Accepted2/21ms2860 KiB
9Accepted2/21ms2880 KiB
10Accepted2/21ms2900 KiB
11Accepted2/26ms3316 KiB
12Accepted2/216ms4192 KiB
13Accepted2/21ms3420 KiB
14Accepted2/239ms6868 KiB
15Accepted2/229ms8016 KiB
16Accepted2/234ms9164 KiB
17Accepted4/432ms10228 KiB
18Accepted6/639ms11488 KiB
19Accepted6/635ms12620 KiB
20Accepted6/632ms13736 KiB