7854 2024. 01. 11 13:25:12 szabelr Síkság (55) cpp17 Hibás válasz 0/55 64ms 13492 KiB
// Síkság.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <set>
using namespace std;
int tomb[100001];
int main()
{
    int n,x,most,max=0,z,kez=1,veg=1,kezmax,kezveg;
    cin >> n;
    cin >> x;
    multiset<int> multiset;
    multiset.insert(x);
    tomb[1] = x;
    for (int i = 2; i <= n; i++)
    {
        cin >> x;
        tomb[i] = x;
        if ((x - *multiset.begin() == 0 or x - *multiset.begin() == 1 or x - *multiset.begin() == -1) and (*multiset.rbegin() - x != 2 and *multiset.rbegin() - x != -2) ) {
            multiset.insert(x);
            //cout << "fel" << " " << x << endl;
        }

        else
        {
            //cout << "ennyi" ;
            //cout << i << " ";
            most = multiset.size()-1;
            if (most > max) {
                max = most;
                kez= i-(multiset.size()-1);
                veg = i;
                max = most;
            }                
            z = *multiset.begin();
            multiset.erase(tomb[i- multiset.size()+1]);
            multiset.insert(x);
            //cout << *multiset.rbegin() << endl;
        }
    }
    cout << max<<" ";
    cout << kez<< " ";
}

// 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 Összpont Teszt Verdikt Idő Memória
base 0/55
1 Elfogadva 0/0 3ms 1816 KiB
2 Hibás válasz 0/0 7ms 2232 KiB
3 Hibás válasz 0/2 3ms 2284 KiB
4 Hibás válasz 0/2 3ms 2420 KiB
5 Hibás válasz 0/2 3ms 2492 KiB
6 Hibás válasz 0/2 3ms 2560 KiB
7 Hibás válasz 0/3 3ms 2516 KiB
8 Hibás válasz 0/2 3ms 2780 KiB
9 Hibás válasz 0/3 3ms 2804 KiB
10 Hibás válasz 0/3 7ms 3464 KiB
11 Hibás válasz 0/3 7ms 4308 KiB
12 Hibás válasz 0/3 7ms 4368 KiB
13 Hibás válasz 0/3 61ms 13492 KiB
14 Hibás válasz 0/3 43ms 7468 KiB
15 Hibás válasz 0/3 50ms 10008 KiB
16 Hibás válasz 0/3 56ms 8552 KiB
17 Hibás válasz 0/3 57ms 9124 KiB
18 Hibás válasz 0/3 61ms 12396 KiB
19 Hibás válasz 0/3 64ms 13176 KiB
20 Hibás válasz 0/3 59ms 12544 KiB
21 Hibás válasz 0/3 30ms 8060 KiB
22 Hibás válasz 0/3 46ms 8484 KiB