59522023-10-06 10:22:28mmatedRobotokcpp17Accepted 50/5064ms16592 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

int lis(vector<int>& p)
{
    vector<int> s;
    int m=p.size();
    f(i,0,m)
    {
        auto it = lower_bound(s.begin(),s.end(),p[i]);
        if(it==s.end())  s.push_back(p[i]);
        else    *it=p[i];
    }
    return s.size();
}
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<int>> a;
    int x,y;
    f(i,0,k)
    {
        cin>>x>>y;
        a.push_back({x,y});
    }
    sort(a.begin(),a.end(),greater<>());
    vector<int> b;
    f(i,0,k)    b.push_back(a[i][1]);
   /* int c=1;
    int asd=k-1;
    vector<int> w=a[0];
    while(a[asd][0]==a[k-1][0])
    {
        w=a[asd];
        asd--;
    } 
    //cout<<w[0]<<" "<<w[1]<<"\t"<<asd<<"\n";
    while(asd>=0)
    {
        if(a[asd][0]<w[0] && a[asd][1]>w[1]) 
        {
            vector<int> m=a[asd];
            while(asd>=1 && a[asd-1][0]<w[0] && a[asd-1][1]>w[1] && a[asd-1][0]==m[0]) asd--;
            //cout<<a[asd][0]<<" "<<a[asd][1]<<"\n";
            c++;   
            w=a[asd]; 
        }
        asd--; 
    } 
    cout<<c;*/
    cout<<lis(b);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1700 KiB
2Accepted0/050ms12488 KiB
3Accepted2/23ms2272 KiB
4Accepted2/23ms2360 KiB
5Accepted2/23ms2544 KiB
6Accepted2/24ms3496 KiB
7Accepted2/24ms3480 KiB
8Accepted2/24ms3264 KiB
9Accepted2/23ms3348 KiB
10Accepted2/23ms3576 KiB
11Accepted2/28ms5864 KiB
12Accepted2/228ms9528 KiB
13Accepted2/23ms3572 KiB
14Accepted2/259ms16032 KiB
15Accepted2/246ms16032 KiB
16Accepted2/264ms16036 KiB
17Accepted4/445ms16428 KiB
18Accepted6/639ms16380 KiB
19Accepted6/648ms16324 KiB
20Accepted6/643ms16592 KiB