30782023-02-14 12:05:41tamasmarkKéséscpp17Futási hiba 40/5054ms38496 KiB
// keses.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <climits>

using namespace std;

struct adat
{
   unsigned long long db, pillanat;
};

unsigned long long n, i, mini,maxi,keses;
vector< unsigned long long>x;
vector<adat>y;

int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    x.resize(n + 1);
    y.resize(999999);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
        if (x[i] < mini) mini = x[i];
        if (x[i] > maxi) maxi = x[i];
        if (!y[x[i]].db)
        {
            y[x[i]].db++;
            y[x[i]].pillanat = i;
        }
        else
        {
            if (y[x[i]].pillanat < i) y[x[i]].pillanat = i;
        }
    }
    keses = LLONG_MAX;
    for (i = mini; i <= maxi; ++i)
    {
        if (y[i].db)
        {
            if (y[i].pillanat < keses) keses = y[i].pillanat;
        }
    }
    cout << keses;
    return 0;
}
/*
6
1848 1849 1848 1849 895 1516
*/
// 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/50
1Elfogadva0/014ms32984 KiB
2Elfogadva0/017ms33672 KiB
3Elfogadva5/514ms33496 KiB
4Elfogadva5/513ms33424 KiB
5Elfogadva5/534ms36752 KiB
6Elfogadva5/532ms36932 KiB
7Elfogadva4/452ms37148 KiB
8Elfogadva4/446ms37408 KiB
9Elfogadva4/454ms37572 KiB
10Elfogadva4/452ms37580 KiB
11Elfogadva4/452ms37584 KiB
12Futási hiba0/214ms37952 KiB
13Futási hiba0/214ms37952 KiB
14Futási hiba0/114ms38248 KiB
15Futási hiba0/117ms38232 KiB
16Futási hiba0/117ms38496 KiB
17Futási hiba0/117ms38408 KiB
18Futási hiba0/117ms38444 KiB
19Futási hiba0/117ms38416 KiB