135982025-01-08 10:59:07BravoSíkság (55)cpp17Runtime error 11/55300ms2136 KiB
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <climits>
using namespace std;

struct pont{
    int x,y;
};
int main()
{
    set<int> ap;
    vector<int> p;
    vector<pont> q;
    vector<int> w;
    //ifstream f("sik.txt");
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    pont A;
    int c=0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(a[j]+1==a[i] || a[j]-1==a[i] || a[j]==a[i]){
                c++;
            }
            else{
                A.y=j-1;
                j=n;
            }
        }
        if(c!=0 && c!=1){
            for(int j=i;j<A.y;j++){
                A.x=a[j];
                p.push_back(A.x);
            }
            int t=p.size();
            for(int r=0;r<t;r++){
                ap.insert(p[r]);
            }
            int h;
            h=ap.size();
            A.x=i;
            if(h<=2){
                w.push_back(c);
                q.push_back(A);
            }

        }
        p.clear();
        ap.clear();
        c=0;
    }
    c=INT_MIN;
    int x=w.size();
    int e;
    for(int i=0;i<x;i++){
        if(w[i]>c){
            c=w[i];
            e=i;
        }
    }
    A=q[e];
    cout << c << " " << A.x+1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base11/55
1Accepted0/01ms512 KiB
2Accepted0/093ms500 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Runtime error0/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Accepted2/23ms316 KiB
9Wrong answer0/32ms316 KiB
10Time limit exceeded0/3215ms448 KiB
11Wrong answer0/37ms564 KiB
12Time limit exceeded0/3284ms692 KiB
13Accepted3/346ms2136 KiB
14Time limit exceeded0/3277ms820 KiB
15Time limit exceeded0/3300ms824 KiB
16Time limit exceeded0/3284ms824 KiB
17Time limit exceeded0/3282ms820 KiB
18Time limit exceeded0/3287ms1076 KiB
19Time limit exceeded0/3280ms1060 KiB
20Time limit exceeded0/3286ms1260 KiB
21Time limit exceeded0/3277ms564 KiB
22Time limit exceeded0/3284ms820 KiB