30112023-02-08 10:54:03bzsofiaKártyajátékcpp11Accepted 30/3090ms6864 KiB
// kartyajatek.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>

using namespace std;

long long i, n, m, db, pont;
deque <long long> sorrend;

int main()
{
    cin >> m >> n;
    vector <long long> kevert(n + 1);

    for (i = 1; i <= n; ++i)
    {
        cin >> kevert[i];
        sorrend.push_front(kevert[i]);
    }

    sort(sorrend.begin(), sorrend.end());

    for (i = 1; i <= n; ++i)
    {
        if (!sorrend.empty() && sorrend.front() <= kevert[i])
        {
            db = 0;
            while (sorrend.front() != kevert[i])
            {
                sorrend.pop_front();
                ++db;
            }
            sorrend.pop_front();

            if (db >= 1) ++pont;
        }
    }

    cout << pont;

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1808 KiB
2Accepted0/090ms5096 KiB
3Accepted1/13ms2268 KiB
4Accepted1/13ms2528 KiB
5Accepted1/13ms2600 KiB
6Accepted2/23ms2960 KiB
7Accepted2/23ms2988 KiB
8Accepted2/23ms3200 KiB
9Accepted1/134ms5332 KiB
10Accepted2/248ms6328 KiB
11Accepted3/348ms6632 KiB
12Accepted3/348ms6540 KiB
13Accepted1/189ms6740 KiB
14Accepted2/289ms6696 KiB
15Accepted3/387ms6732 KiB
16Accepted3/390ms6864 KiB
17Accepted3/389ms6828 KiB