24152023-01-12 18:42:42sztomiRobotokcpp11Accepted 50/5037ms7100 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, k;
    cin >> n >> m >> k;
    vector<pii> pontok(k);
    for(int i = 0; i < k; i++){
        cin >> pontok[i].first >> pontok[i].second;
    }
    sort(pontok.begin(), pontok.end());
    vector<int> oszlop(k);
    for(int i = 0; i < k; i++){
        oszlop[i] = pontok[i].second;
    }

    vector<int> akt;
    for(int i = 0; i < k; i++){
        //sort(akt.begin(), akt.end());
        auto it = lower_bound(akt.begin(), akt.end(), oszlop[i], greater<int>());
        if(it == akt.end()){
            akt.push_back(oszlop[i]);
        }
        else{
            *it = oszlop[i];
        }
/*
        for(int x : akt){
            cout << x << " ";
        }
        cout << "\n";
*/
    }
    cout << akt.size() << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/032ms3900 KiB
3Accepted2/22ms2256 KiB
4Accepted2/22ms2560 KiB
5Accepted2/22ms2440 KiB
6Accepted2/23ms2560 KiB
7Accepted2/23ms2808 KiB
8Accepted2/23ms2736 KiB
9Accepted2/23ms3012 KiB
10Accepted2/22ms3088 KiB
11Accepted2/26ms3424 KiB
12Accepted2/219ms4036 KiB
13Accepted2/22ms3284 KiB
14Accepted2/232ms6552 KiB
15Accepted2/228ms6756 KiB
16Accepted2/237ms6708 KiB
17Accepted4/428ms6852 KiB
18Accepted6/629ms6948 KiB
19Accepted6/632ms7100 KiB
20Accepted6/626ms7048 KiB