78632024-01-11 14:03:08szasztundeSíkság (55)cpp17Wrong answer 0/5563ms13880 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> h;
    h.insert(x);
    tomb[1] = x;
    for (int i = 2; i <= n; i++)
    {
        cin >> x;
        tomb[i] = x;
        if ((x - *h.begin() == 0 or x - *h.begin() == 1 or x - *h.begin() == -1) and (*h.rbegin() - x != 2 and *h.rbegin() - x != -2) ) {
            h.insert(x);
            //cout << "be" << " " << x << endl;
        }

        else
        {
            /*cout << " i=" ;
            cout << i << " ";*/
            most = h.size() - 1;
            /*cout << " meret=" << most << endl;*/
            if (most > max) {
                max = most;
                kez= i-(h.size()-1);
                veg = i;
                max = most;
            }
            //cout<<" max="<<max<<" Halmaz: ";
            z = *h.begin();
            /*multiset <int>::iterator it;
            for (it = h.begin(); it != h.end(); ++it) {
                cout << *it << " ";
            }
            cout<<"Torlendo:"<<tomb[i- h.size()+2]<<endl;*/
            h.erase(tomb[i- h.size()+1]);
            h.insert(x);
            //cout << i - (h.size() - 1) << endl;
        }
    }
    cout << max<<" ";
    cout << kez<< " ";
}

SubtaskSumTestVerdictTimeMemory
base0/55
1Accepted0/03ms1816 KiB
2Wrong answer0/06ms2224 KiB
3Wrong answer0/23ms2332 KiB
4Wrong answer0/23ms2336 KiB
5Wrong answer0/23ms2532 KiB
6Wrong answer0/23ms2772 KiB
7Wrong answer0/33ms2896 KiB
8Wrong answer0/23ms3272 KiB
9Wrong answer0/33ms3336 KiB
10Wrong answer0/37ms3740 KiB
11Wrong answer0/36ms4428 KiB
12Wrong answer0/37ms4708 KiB
13Wrong answer0/361ms13880 KiB
14Wrong answer0/343ms7736 KiB
15Wrong answer0/348ms10468 KiB
16Wrong answer0/356ms9352 KiB
17Wrong answer0/357ms9692 KiB
18Wrong answer0/361ms12968 KiB
19Wrong answer0/363ms13836 KiB
20Wrong answer0/359ms13328 KiB
21Wrong answer0/329ms8772 KiB
22Wrong answer0/346ms9308 KiB