74022024-01-08 14:12:23CWMKártyajátékcpp17Hibás válasz 29/3086ms7440 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 (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/03ms1812 KiB
2Elfogadva0/086ms4736 KiB
3Elfogadva1/13ms2220 KiB
4Hibás válasz0/13ms2296 KiB
5Elfogadva1/13ms2448 KiB
6Elfogadva2/23ms2444 KiB
7Elfogadva2/23ms2568 KiB
8Elfogadva2/23ms2564 KiB
9Elfogadva1/130ms4004 KiB
10Elfogadva2/246ms5484 KiB
11Elfogadva3/348ms5792 KiB
12Elfogadva3/346ms5872 KiB
13Elfogadva1/183ms5100 KiB
14Elfogadva2/285ms5724 KiB
15Elfogadva3/385ms7440 KiB
16Elfogadva3/386ms6528 KiB
17Elfogadva3/385ms6384 KiB