73042024-01-06 16:02:41KristófTakaros Sorozat (80 pont)cpp17Wrong answer 6/80500ms3968 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    bool ell=false;
    bool ell2=false;
    cin>>n;
    int s[n];
    int s2[n];
    for (int i=0;i<n;i++){
        cin>>s[i];
        s2[i]=s[i];
    }
    bool nulla=false;
    bool end=false;
    int m=0;
    if(s[0]==0){
        m=1;
    }
    int ans=0;
    int ans2=0;
            for(int l=n-1;l>-1;l--){
            if(s[l]!=1){
                ell=true;
            }
            if(ell==true && s[l]==1){
                nulla=false;
                break;
            }
           nulla=true;
        }
        if(nulla==true){
            cout<<0<<endl<<0<<endl;
            return 0;
        }
    while(end==false){
        ell=false;
        if(s[0]==0){
        m=1;
    }
    else m=0;
        for(int i=m;i<n-1;i++){
            if(s[i]+s[i+1]==1){
                s[i]=0;
                s[i+1]=0;
                if(m==1){
                    s[i]=1;
                    s[i+1]=1;
                }
                ans++;
                break;
            }

        }
        for(int l=n-1;l>-1;l--){
            if(s[l]!=1){
                ell=true;
            }
            if(ell==true && s[l]==1){
                end=false;
                break;
            }
            end=true;
        }
    }
    cout<<ans<<endl;
bool end2=false;
    int m2=0;
    if(s2[0]==0){
        m2++;
    }
    while(end2==false){
        for(int i=m2;i<n-3;i++){
            if(s2[i]+s2[i+1]+s2[i+2]+s2[i+3]==2){
                s2[i]=0;
                s2[i+1]=0;
                s2[i+2]=0;
                s2[i+3]=0;
                if(m2=1){
                    s2[i]=1;
                    s2[i+1]=1;
                    s2[i+2]=1;
                    s2[i+3]=1;
                }
                ans2++;
                break;
            }
        }
        for(int i=m2;i<n-1;i++){
            if(s2[i]+s[i+1]==1){
                s2[i]=0;
                s2[i+1]=0;
                if(m2==1){
                    s2[i]=1;
                    s2[i+1]=1;
                }
                ans2++;
                break;
            }

        }
        for(int l=n-1;l>-1;l--){
            if(s2[l]!=1){
                ell2=true;
            }
            if(ell2==true && s2[l]==1){
                end2=false;
                break;
            }
            end2=true;
        }
    }
    cout<<ans2<<endl;



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/80
1Wrong answer0/03ms1872 KiB
2Time limit exceeded0/0500ms1984 KiB
3Accepted4/43ms2276 KiB
4Wrong answer0/43ms2676 KiB
5Partially correct2/43ms2704 KiB
6Wrong answer0/43ms2780 KiB
7Wrong answer0/43ms2920 KiB
8Wrong answer0/42ms3008 KiB
9Wrong answer0/42ms3068 KiB
10Wrong answer0/42ms3064 KiB
11Wrong answer0/43ms3312 KiB
12Wrong answer0/43ms3284 KiB
13Time limit exceeded0/4500ms3128 KiB
14Time limit exceeded0/4437ms3188 KiB
15Time limit exceeded0/4469ms3520 KiB
16Time limit exceeded0/4469ms3520 KiB
17Time limit exceeded0/4453ms3572 KiB
18Time limit exceeded0/4469ms3516 KiB
19Time limit exceeded0/4481ms3404 KiB
20Time limit exceeded0/4474ms3468 KiB
21Time limit exceeded0/4469ms3664 KiB
22Time limit exceeded0/4437ms3968 KiB