36342023-03-01 12:43:001478Kártyajátékcpp17Accepted 30/3046ms7788 KiB
#include <bits/stdc++.h>  
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
int main()
{
    fast_cin();
    //ifstream cin("in.txt");
    long long n;
    cin >> n;
    int k;
    cin >> k;
    vector<long long> cards(k + 1), orderedCards(k + 1);

    for(int i = 1; i <= k; i++){
        cin >> cards[i];
        orderedCards[i] = cards[i];
    }

    sort(all(orderedCards));
    vector<int> indexes(k + 1);
    for(int i = 1; i <= k; i++){
        indexes[i] = lower_bound(all(orderedCards), cards[i]) - orderedCards.begin();
    }

    int maxind = 0;
    int db = 0;
    for(int i = 1; i <= k; i++){
        if(indexes[i] > maxind){
            if(indexes[i] > maxind + 1){
                db++;
            }
            maxind = indexes[i];
        }
    }


    cout << db;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1824 KiB
2Accepted0/043ms5952 KiB
3Accepted1/13ms2232 KiB
4Accepted1/13ms2312 KiB
5Accepted1/13ms2444 KiB
6Accepted2/23ms2552 KiB
7Accepted2/23ms2808 KiB
8Accepted2/23ms3020 KiB
9Accepted1/126ms5704 KiB
10Accepted2/235ms7176 KiB
11Accepted3/332ms7368 KiB
12Accepted3/334ms7372 KiB
13Accepted1/146ms7656 KiB
14Accepted2/245ms7748 KiB
15Accepted3/341ms7788 KiB
16Accepted3/343ms7704 KiB
17Accepted3/343ms7708 KiB