245932026-02-12 21:51:51pirosmacska10Síkság (55)cpp17Wrong answer 34/5514ms1724 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <cmath>
#include <queue>

using namespace std;
using ll=long long;

const ll INF=LLONG_MAX;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> nums(n);
    for(int i = 0; i < n; i++) {
        cin >> nums[i];
    }   


    int bottom = nums[0];
    int l = 0;
    vector<int> cnt(100'001, 0);
    vector<int> last(100'001, -1);
    int maxx = 0;
    int max_start = 0;
    for(int r = 1; r < n; r++) {
        cnt[nums[r]]++;
        last[nums[r]] = r;
        if(nums[r] < bottom) {
            while (l <= last[bottom+1]) {
                cnt[nums[l++]]--;
            }
            bottom = nums[r];
        }
        else if(nums[r] > bottom+1) {
            while (l <= last[bottom]) {
                cnt[nums[l++]]--;
            }
            bottom = nums[r]-1;
        }
        if(r-l+1 > maxx) {
            maxx = r-l+1;
            max_start = l;
        }
    }
    cout << maxx << " " << max_start+1;
}
SubtaskSumTestVerdictTimeMemory
base34/55
1Accepted0/02ms1076 KiB
2Accepted0/03ms1076 KiB
3Wrong answer0/22ms1076 KiB
4Wrong answer0/22ms1076 KiB
5Wrong answer0/21ms1076 KiB
6Accepted2/21ms1076 KiB
7Accepted3/31ms1080 KiB
8Accepted2/22ms1076 KiB
9Accepted3/32ms1076 KiB
10Accepted3/33ms1076 KiB
11Accepted3/33ms1076 KiB
12Accepted3/32ms1076 KiB
13Wrong answer0/313ms1588 KiB
14Accepted3/38ms1588 KiB
15Accepted3/310ms1600 KiB
16Accepted3/313ms1588 KiB
17Wrong answer0/313ms1724 KiB
18Wrong answer0/314ms1600 KiB
19Wrong answer0/313ms1588 KiB
20Wrong answer0/313ms1600 KiB
21Accepted3/37ms1420 KiB
22Accepted3/310ms1444 KiB