74032024-01-08 14:22:08CWMKártyajátékcpp17Hibás válasz 29/3093ms6628 KiB
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define ll long long
int main()
{
    ll i1;
    int n;
    cin >> i1 >> n;
    vector<ll> ord(n);
    ll max = -1;
    ll Secmax = -1;
    ll SecmaxATP = -1;
    vector<ll> maxVec;
    int res = 0;
    for (size_t i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        ord[i] = a;
        if (a > max) {
            if(SecmaxATP==-1) maxVec.push_back(a);
            if (a == i1) {
                SecmaxATP = max;
                if (max == -1) {
                    max = i1;
                }
            }
            else {
                Secmax = a;
                max = a;
            }
        }
    }
    if (n==3 && Secmax == SecmaxATP) res--;
    if (maxVec.size() == 1) {
        if (n == 1) cout << 0;
        else cout << 1;
        return 0;
    }
    sort(ord.begin(), ord.end());
    if (maxVec[0] != ord[0]) res++;
    int insVec = 1;
    for (size_t i = 0; i < ord.size(); i++)
    {
        if (ord[i] == maxVec[insVec]) {
            if (i != insVec) {
                if (i == ord.size() - 1) {
                    res++;
                    break;
                }
                if (ord[i + 1] != maxVec[insVec + 1]) {
                    res++;
                }
            }
            insVec++;
        }
    }
    if (res == -1) res = 0;
    cout << res;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base29/30
1Elfogadva0/03ms1836 KiB
2Elfogadva0/093ms4648 KiB
3Elfogadva1/13ms2060 KiB
4Hibás válasz0/13ms2100 KiB
5Elfogadva1/13ms2308 KiB
6Elfogadva2/23ms2524 KiB
7Elfogadva2/23ms2604 KiB
8Elfogadva2/23ms2600 KiB
9Elfogadva1/132ms3660 KiB
10Elfogadva2/248ms5256 KiB
11Elfogadva3/348ms5432 KiB
12Elfogadva3/348ms5348 KiB
13Elfogadva1/193ms4384 KiB
14Elfogadva2/292ms4960 KiB
15Elfogadva3/392ms6628 KiB
16Elfogadva3/393ms5724 KiB
17Elfogadva3/392ms5896 KiB