167812025-05-13 09:03:46BencuÖsszegzésekcpp17Partially correct 10/10017ms564 KiB
#include <iostream>

using namespace std;
int n,a[10001],mi,ma,st[10001],s,s1;

/*bool Jo(int szint) {
    if (s[szint]>n) return false;
    if (st[szint]>st[szint-1]) return false;
    return true;
}
void Back(int szint) {
    if (s[szint-1]==n) {
        for (int i=1; i<szint-1; i++) cout<<st[i]<<"+";
        cout<<st[szint-1]<<" "<<endl<<" ";
        //for (int i=1; i<szint-1; i++) cout<<s[i]<<"+";
        //cout<<s[szint-1]<<" "<<endl;
    }
    else {
        for (int i=1; i<=n; i++) {
            st[szint]=i;
            s[szint]=s[szint-1]+i;
            if (Jo(szint)) {
                Back(szint+1);
            }
        }
    }
}*/
void Back1 (int szint) {
    int i=szint,t=0;
    for (int j=1; j<=szint; j++) st[j]=a[j];
    while (st[i]==1) {
        i--;
        t++;
    }
    for (int j=1; j<i; j++) cout<<a[j]<<" ";
    cout<<a[i]-1<<" ";
    for (i; i<=szint; i++) cout<<1<<" ";
}
void Back2 (int szint) {
    if (a[n]==a[n-1]) {
        int i=n,sz=0;
        while (a[i]==a[i-1]) {
            sz=sz+a[i];
            i--;
        }
        sz=sz+a[i];
        for (int j=1; j<i; j++) cout<<a[j]<<" ";
        cout<<a[i]+1<<" ";
        //cout<<endl<<sz<<endl;
        sz=sz-a[i]-1;
        while (sz>0) {
            cout<<1<<" ";
            sz--;
        }
    }
    else {
        int i=n-1,sz=0;
        while (a[i]==a[i-1]) {
            sz=sz+a[i];
            i--;
        }
        sz++;
        for (int j=1; j<i; j++) cout<<a[j]<<" ";
        cout<<a[i]+1<<" ";
        while (sz>0) {
            cout<<1<<" ";
            sz--;
        }
        //for (int j=i+1; j<n; j++) cout<<a[j]<<" ";
        //if ((a[n]-1)>0) cout<<a[n]-1;
    }
}


int main()
{
    cin>>n;
    //s[0]=0;
    //st[0]=INT_MAX;
    //Back(1);
    bool bencu=true;
    for (int i=1; i<=n; i++) {
            cin>>a[i];
            if (i>1 && a[i]!=a[i-1]) bencu=false;
            if (a[i]==1) s1++;
            st[i]=st[i-1]+a[i];
            if (a[i]<mi) mi=a[i];
            if (a[i]>ma) ma=a[i];
            s=s+a[i];
            }
    //cout<<endl<<s1<<endl;
    if (n==s) cout<<0;
    else {
        if (bencu) {
            int t=a[1]+1,sz=s;
            cout<<t<<" ";
            sz=sz-t;
            while (sz>0) {
                cout<<1<<" ";
                sz--;
            }
        }
        else Back2(n);
    }
    cout<<endl;
    if (n==1) cout<<0;
    else {
        if (n==s1+1) {
            int t=a[1]-1,sz=s;
            while (sz-t>0) {
                cout<<t<<" ";
                sz=sz-t;
            }
            cout<<sz<<endl;
        }
        else Back1(n);
    }
    cout<<endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Partially correct1ms316 KiB
2Accepted1ms316 KiB
3Accepted1ms316 KiB
subtask20/6
4Accepted1ms316 KiB
5Wrong answer1ms316 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
8Wrong answer1ms316 KiB
subtask30/6
9Wrong answer1ms316 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer4ms316 KiB
13Wrong answer4ms316 KiB
subtask40/10
14Wrong answer1ms316 KiB
15Wrong answer1ms316 KiB
16Wrong answer1ms316 KiB
17Wrong answer4ms316 KiB
18Wrong answer4ms316 KiB
19Accepted1ms316 KiB
20Accepted2ms340 KiB
21Accepted14ms564 KiB
22Accepted17ms564 KiB
23Accepted14ms540 KiB
subtask55/10
24Partially correct2ms316 KiB
25Partially correct2ms316 KiB
26Partially correct2ms316 KiB
27Partially correct2ms508 KiB
28Partially correct1ms316 KiB
subtask65/10
29Partially correct1ms316 KiB
30Partially correct1ms316 KiB
31Partially correct1ms316 KiB
32Accepted1ms316 KiB
33Partially correct1ms316 KiB
subtask70/58
34Partially correct1ms316 KiB
35Accepted1ms316 KiB
36Accepted1ms316 KiB
37Accepted1ms316 KiB
38Wrong answer1ms316 KiB
39Wrong answer1ms316 KiB
40Wrong answer1ms316 KiB
41Wrong answer1ms316 KiB
42Wrong answer1ms316 KiB
43Wrong answer1ms316 KiB
44Wrong answer1ms316 KiB
45Wrong answer4ms316 KiB
46Wrong answer4ms316 KiB
47Accepted1ms316 KiB
48Accepted2ms340 KiB
49Accepted14ms564 KiB
50Accepted17ms564 KiB
51Partially correct1ms316 KiB
52Partially correct1ms316 KiB
53Partially correct1ms316 KiB
54Partially correct1ms316 KiB
55Accepted1ms316 KiB
56Partially correct1ms316 KiB
57Accepted1ms316 KiB
58Accepted1ms316 KiB
59Partially correct1ms316 KiB
60Partially correct1ms396 KiB
61Partially correct1ms384 KiB
62Accepted1ms316 KiB
63Accepted2ms328 KiB
64Accepted2ms508 KiB
65Accepted3ms508 KiB
66Accepted4ms496 KiB