194112025-12-08 15:29:51KissCsongor777Díjazás több helyezettnekcpp17Wrong answer 0/801ms508 KiB
#include <iostream>

using namespace std;

int s[20]={0},a,b,c=0,d=0;

struct par
{
    int x,y;
}ab;

par keres(int x[],int g)
{
    a=g+1; b=0; c=0; d=g+1;
    for(int i=1; i<=g; i++)
    {
        if(i!=g)if(x[i]>=x[i+1]+2){d=a; a=i;}
        if(i!=1 && c==0)if(x[i]<=x[i-1]-2){if(b==0)b=i;else c=i;}
            if(a==b-1 && x[a]==x[b]+2 || a==b)if(c!=0)b=c;else a=d;
    }

    if(a>b){swap(a,b);a--;b++;}
    ab.x=a; ab.y=b;
    return ab;
}

int main()
{
    int h,e,a1,a2;
    cin>>h>>e;

    int H[h+1];

    H[1]=e-h*(h-1)/2;
    for(int i=2; i<=h; i++)H[i]=h-i+1;


    for(int i=1; i<=h; i++)cout<<H[i]<<" ";
    /**cout<<endl;
    cout<<keres(H,h).x<<" "<<keres(H,h).y;**/

    a1=keres(H,h).x; a2=keres(H,h).y;
    while(a1<=h && a1>=1 && a2!=0)
    {
        H[a1]--;
        H[a2]++;
        cout<<endl;
        for(int i=1; i<=h; i++)cout<<H[i]<<" ";
        ///cout<<endl;
        ///cout<<a1<<" "<<a2;
        a1=keres(H,h).x; a2=keres(H,h).y;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Wrong answer1ms316 KiB
subtask20/5
3Accepted1ms360 KiB
4Wrong answer1ms500 KiB
5Wrong answer1ms408 KiB
6Wrong answer1ms316 KiB
7Wrong answer1ms316 KiB
subtask30/5
8Accepted1ms316 KiB
9Wrong answer1ms316 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
subtask40/15
13Accepted1ms316 KiB
14Wrong answer1ms316 KiB
15Wrong answer1ms316 KiB
16Wrong answer1ms316 KiB
17Wrong answer1ms316 KiB
subtask50/15
18Wrong answer1ms316 KiB
19Wrong answer1ms500 KiB
20Wrong answer1ms316 KiB
21Wrong answer1ms316 KiB
22Wrong answer1ms316 KiB
subtask60/15
23Accepted1ms316 KiB
24Wrong answer1ms316 KiB
25Wrong answer1ms316 KiB
26Wrong answer1ms500 KiB
27Wrong answer1ms316 KiB
28Wrong answer1ms316 KiB
29Wrong answer1ms316 KiB
30Wrong answer1ms316 KiB
31Wrong answer1ms316 KiB
32Wrong answer1ms316 KiB
33Wrong answer1ms316 KiB
34Wrong answer1ms316 KiB
35Wrong answer1ms316 KiB
36Wrong answer1ms316 KiB
37Wrong answer1ms316 KiB
38Wrong answer1ms316 KiB
39Wrong answer1ms316 KiB
subtask70/25
40Accepted1ms316 KiB
41Wrong answer1ms316 KiB
42Accepted1ms360 KiB
43Wrong answer1ms500 KiB
44Wrong answer1ms408 KiB
45Wrong answer1ms316 KiB
46Wrong answer1ms316 KiB
47Accepted1ms316 KiB
48Wrong answer1ms316 KiB
49Wrong answer1ms316 KiB
50Wrong answer1ms316 KiB
51Wrong answer1ms316 KiB
52Accepted1ms316 KiB
53Wrong answer1ms316 KiB
54Wrong answer1ms316 KiB
55Wrong answer1ms316 KiB
56Wrong answer1ms316 KiB
57Wrong answer1ms316 KiB
58Wrong answer1ms500 KiB
59Wrong answer1ms316 KiB
60Wrong answer1ms316 KiB
61Wrong answer1ms316 KiB
62Wrong answer1ms316 KiB
63Wrong answer1ms316 KiB
64Wrong answer1ms316 KiB
65Wrong answer1ms316 KiB
66Wrong answer1ms316 KiB
67Wrong answer1ms316 KiB
68Wrong answer1ms316 KiB
69Wrong answer1ms316 KiB
70Wrong answer1ms316 KiB
71Wrong answer1ms316 KiB
72Wrong answer1ms316 KiB
73Wrong answer1ms316 KiB
74Wrong answer1ms404 KiB
75Wrong answer1ms508 KiB
76Wrong answer1ms316 KiB
77Wrong answer1ms316 KiB
78Wrong answer1ms316 KiB
79Wrong answer1ms316 KiB
80Wrong answer1ms316 KiB
81Wrong answer1ms316 KiB