45662023-03-29 21:26:00Valaki2Kártyajátékcpp14Accepted 30/3059ms13720 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

const int inf = 1e18 + 42;

void solve() {
    int m, n;
    cin >> m >> n;
    vector<int> v(n);
    for(int &x : v) {
        cin >> x;
    }
    set<int> d;
    set<int> good;
    for(const int &x : v) {
        auto it = d.lower_bound(x);
        if(it == d.end()) {
            d.insert(x);
        } else {
            good.insert(*it);
        }
    }
    cout << (int) good.size() << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1824 KiB
2Accepted0/059ms10280 KiB
3Accepted1/13ms2248 KiB
4Accepted1/13ms2456 KiB
5Accepted1/13ms2668 KiB
6Accepted2/23ms3024 KiB
7Accepted2/23ms3268 KiB
8Accepted2/23ms3300 KiB
9Accepted1/124ms4856 KiB
10Accepted2/248ms9996 KiB
11Accepted3/348ms13040 KiB
12Accepted3/348ms11800 KiB
13Accepted1/141ms5512 KiB
14Accepted2/257ms9828 KiB
15Accepted3/356ms13720 KiB
16Accepted3/357ms11080 KiB
17Accepted3/359ms12264 KiB