78542024-01-11 13:25:12szabelrSíkság (55)cpp17Wrong answer 0/5564ms13492 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
SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/03ms1816 KiB
2Wrong answer0/07ms2232 KiB
3Wrong answer0/23ms2284 KiB
4Wrong answer0/23ms2420 KiB
5Wrong answer0/23ms2492 KiB
6Wrong answer0/23ms2560 KiB
7Wrong answer0/33ms2516 KiB
8Wrong answer0/23ms2780 KiB
9Wrong answer0/33ms2804 KiB
10Wrong answer0/37ms3464 KiB
11Wrong answer0/37ms4308 KiB
12Wrong answer0/37ms4368 KiB
13Wrong answer0/361ms13492 KiB
14Wrong answer0/343ms7468 KiB
15Wrong answer0/350ms10008 KiB
16Wrong answer0/356ms8552 KiB
17Wrong answer0/357ms9124 KiB
18Wrong answer0/361ms12396 KiB
19Wrong answer0/364ms13176 KiB
20Wrong answer0/359ms12544 KiB
21Wrong answer0/330ms8060 KiB
22Wrong answer0/346ms8484 KiB