167882025-05-13 11:25:24ercseferencÖsszegzésekcpp17Részben helyes 55/1004ms820 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,s=0;cin>>n;
    int b[n];
    for(int i=0; i<n; i++){cin>>b[i]; s+=b[i];}
    int a[s];
    for(int i=0; i<s; i++){
        if(i<n)a[i]=b[i];
        else a[i]=0;}
    int k=s-1;
    while(a[k]==0)k--;
    if(k==0)cout<<0;
    else{
        k--;
        a[k]++;
        int p=0;
        for(int i=0; i<=k; i++)p+=a[i];
        p=s-p;
        for(int i=1; i<=p; i++)a[k+i]=1;
        for(int i=k+p+1; i<s; i++)a[i]=0;
        for(int i=0; i<=k+p; i++)cout<<a[i]<<" ";}
    cout<<endl; k=s-1;
    for(int i=0; i<s; i++){
        if(i<n)a[i]=b[i];
        else a[i]=0;}
    while(a[k]<2 && k>=0)k--;
    if(k==-1)cout<<0;
    else{
        a[k]--; int p=0,c=a[k];
        for(int i=0; i<=k; i++){p+=a[i];}
        p=s-p;
        for(int i=k+1; i<s; i++){a[i]=0;}
        k++;
        while(p-c>0){a[k]=c; k++; p-=c;}
        a[k]=p; int t=0;
        while(a[t]!=0){cout<<a[t]<<" "; t++;}}
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva1ms316 KiB
2Elfogadva1ms316 KiB
3Részben helyes2ms564 KiB
subtask23/6
4Elfogadva1ms316 KiB
5Részben helyes1ms316 KiB
6Elfogadva1ms316 KiB
7Elfogadva1ms316 KiB
8Elfogadva1ms316 KiB
subtask33/6
9Részben helyes1ms316 KiB
10Részben helyes1ms316 KiB
11Részben helyes1ms316 KiB
12Részben helyes2ms316 KiB
13Részben helyes2ms316 KiB
subtask45/10
14Részben helyes1ms316 KiB
15Részben helyes1ms316 KiB
16Részben helyes1ms316 KiB
17Részben helyes2ms316 KiB
18Részben helyes2ms316 KiB
19Részben helyes1ms316 KiB
20Részben helyes1ms316 KiB
21Részben helyes4ms820 KiB
22Részben helyes4ms820 KiB
23Részben helyes4ms680 KiB
subtask510/10
24Elfogadva1ms316 KiB
25Elfogadva1ms328 KiB
26Elfogadva1ms508 KiB
27Elfogadva1ms760 KiB
28Elfogadva2ms728 KiB
subtask65/10
29Elfogadva1ms316 KiB
30Elfogadva1ms316 KiB
31Elfogadva1ms316 KiB
32Elfogadva1ms316 KiB
33Részben helyes1ms316 KiB
subtask729/58
34Elfogadva1ms316 KiB
35Elfogadva1ms316 KiB
36Részben helyes2ms576 KiB
37Elfogadva1ms316 KiB
38Részben helyes1ms316 KiB
39Elfogadva1ms316 KiB
40Elfogadva1ms316 KiB
41Elfogadva1ms316 KiB
42Részben helyes1ms316 KiB
43Részben helyes1ms316 KiB
44Részben helyes1ms316 KiB
45Részben helyes2ms316 KiB
46Részben helyes2ms316 KiB
47Részben helyes1ms316 KiB
48Részben helyes1ms316 KiB
49Részben helyes4ms820 KiB
50Részben helyes4ms820 KiB
51Elfogadva2ms728 KiB
52Elfogadva1ms316 KiB
53Elfogadva1ms316 KiB
54Elfogadva1ms316 KiB
55Elfogadva1ms316 KiB
56Részben helyes1ms316 KiB
57Részben helyes1ms316 KiB
58Részben helyes1ms316 KiB
59Elfogadva1ms316 KiB
60Elfogadva1ms508 KiB
61Elfogadva2ms568 KiB
62Részben helyes2ms564 KiB
63Részben helyes1ms316 KiB
64Részben helyes2ms316 KiB
65Részben helyes3ms820 KiB
66Részben helyes3ms600 KiB