228212026-01-15 19:58:49FintaTihamerSíkság (55)cpp17Wrong answer 0/55289ms780 KiB
#include <iostream>
#include <fstream>
using namespace std;
struct Volgy{
    int k,v;
};
int main1()
{   int n;
    fstream f("be.in");
    f>>n;
    int a[n];
    for(int i=0; i<n; i++){f>>a[i];}
    Volgy o;
    o.k=0;
    o.v=0;
    for(int i=0; i<n; i++){
        if(a[i]-a[i+1] == 1 || a[i]-a[i+1] == -1){
            int s=i;
            int lg=a[i];
            int lk=a[i];
            while(s<n && (lk==lg-1 || lk==lg)){
                if(lg<a[s]) lg=a[s];
                if(lk>a[s]) lk=a[s];
                //cout<<lg-lk<<" "<<a[s]<<"\n";
                s++;
            }
            if((o.v-o.k)<s-i){
                //cout<<1;
                o.k=i-1;
                o.v=s;
            }
        }
    }
    cout<<o.v-o.k<<" "<<o.k;
    return 0;
}
int main()
{   int n;
    fstream f("be.in");
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++){cin>>a[i];}
    Volgy o;
    o.k=0;
    o.v=0;
    for(int i=0; i<n; i++){
        if(a[i]-a[i+1] == 1 || a[i]-a[i+1] == -1){
            int s=i;
            int lg=a[i];
            int lk=a[i];
            while(s<n && (lk==lg-1 || lk==lg)){
                if(lg<a[s]) lg=a[s];
                if(lk>a[s]) lk=a[s];
                //cout<<lg-lk<<" "<<a[s]<<"\n";
                s++;
            }
            if((o.v-o.k)<s-i){
                //cout<<1;
                o.k=i-1;
                o.v=s;
            }
        }
    }
    cout<<o.v-o.k<<" "<<o.k;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/01ms316 KiB
2Accepted0/04ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/36ms508 KiB
11Wrong answer0/33ms560 KiB
12Wrong answer0/345ms428 KiB
13Wrong answer0/330ms704 KiB
14Wrong answer0/317ms636 KiB
15Time limit exceeded0/3268ms780 KiB
16Wrong answer0/341ms768 KiB
17Wrong answer0/382ms760 KiB
18Wrong answer0/332ms568 KiB
19Time limit exceeded0/3289ms564 KiB
20Time limit exceeded0/3226ms632 KiB
21Wrong answer0/361ms760 KiB
22Wrong answer0/3100ms756 KiB