30792023-02-14 12:27:17tamasmarkKéséscpp17Runtime error 40/50335ms59804 KiB
// keses.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

using namespace std;

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

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

int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    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
SubtaskSumTestVerdictTimeMemory
base40/50
1Accepted0/016ms32976 KiB
2Accepted0/034ms35880 KiB
3Accepted5/513ms34032 KiB
4Accepted5/513ms34048 KiB
5Accepted5/5324ms59088 KiB
6Accepted5/5317ms59300 KiB
7Accepted4/4326ms59256 KiB
8Accepted4/4335ms59508 KiB
9Accepted4/4328ms59468 KiB
10Accepted4/4326ms59724 KiB
11Accepted4/4333ms59804 KiB
12Runtime error0/213ms34984 KiB
13Runtime error0/216ms35244 KiB
14Runtime error0/113ms35560 KiB
15Runtime error0/114ms35312 KiB
16Runtime error0/113ms35320 KiB
17Runtime error0/113ms35508 KiB
18Runtime error0/113ms35588 KiB
19Runtime error0/113ms35548 KiB