231982026-01-16 16:47:15tamasnagyDíjazás több helyezettnekcpp17Time limit exceeded 40/80600ms508 KiB
// dijazasTobbFasszal.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;
vector <int> sor;
int hely, ered;

void kiir() {
    for (int i = 0; i < hely; i++) {
        cout << sor[i] << ' ';
    }
    cout << endl;
}

bool hellye() {
    int sum = 0;
    for (int i = 0; i < hely-1; i++) {
        if (sor[i] <= sor[i + 1]) {
            return false;
        }
        sum += sor[i];
    }
    if (sum + sor[hely - 1] == ered) {
        //cout << sum + sor[hely - 1] << endl;
        return true;
    }
    return false;
}

void solve(int h, int e, int depth = 0) {
    //kiir();
    int mini, maxi;
    maxi = e - (h * (h - 1) / 2);
    mini = hely-depth;
    //cout << mini <<" "<< maxi <<" "<< depth << endl;
    for (int i = maxi; i >= mini; i--) {
        sor[depth] = i;
        if (depth < hely) {
            solve(h - 1, e - i, depth+1);
        }
        else {
            if (hellye()) {
                kiir();
            }
        }
    }
}

int main()
{
    cin >> hely >> ered;
    sor.resize(hely+1);
    solve(hely, ered);
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms508 KiB
2Time limit exceeded578ms316 KiB
subtask25/5
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Accepted1ms316 KiB
6Accepted2ms316 KiB
7Accepted2ms316 KiB
subtask35/5
8Accepted1ms316 KiB
9Accepted1ms316 KiB
10Accepted1ms400 KiB
11Accepted2ms316 KiB
12Accepted18ms408 KiB
subtask415/15
13Accepted1ms316 KiB
14Accepted1ms316 KiB
15Accepted1ms316 KiB
16Accepted3ms316 KiB
17Accepted16ms316 KiB
subtask515/15
18Accepted1ms316 KiB
19Accepted14ms316 KiB
20Accepted21ms316 KiB
21Accepted48ms316 KiB
22Accepted8ms316 KiB
subtask60/15
23Accepted1ms316 KiB
24Time limit exceeded579ms500 KiB
25Accepted1ms316 KiB
26Accepted14ms316 KiB
27Accepted21ms316 KiB
28Accepted48ms316 KiB
29Accepted8ms316 KiB
30Accepted312ms316 KiB
31Accepted389ms508 KiB
32Accepted1ms316 KiB
33Accepted9ms316 KiB
34Time limit exceeded600ms316 KiB
35Accepted1ms316 KiB
36Accepted18ms316 KiB
37Time limit exceeded600ms404 KiB
38Time limit exceeded578ms316 KiB
39Accepted14ms316 KiB
subtask70/25
40Accepted1ms316 KiB
41Time limit exceeded579ms500 KiB
42Accepted1ms316 KiB
43Accepted1ms316 KiB
44Accepted1ms316 KiB
45Accepted2ms316 KiB
46Accepted2ms316 KiB
47Accepted1ms316 KiB
48Accepted1ms316 KiB
49Accepted1ms400 KiB
50Accepted2ms316 KiB
51Accepted18ms408 KiB
52Accepted1ms316 KiB
53Accepted1ms316 KiB
54Accepted1ms316 KiB
55Accepted3ms316 KiB
56Accepted16ms316 KiB
57Accepted1ms316 KiB
58Accepted14ms316 KiB
59Accepted21ms316 KiB
60Accepted48ms316 KiB
61Accepted8ms316 KiB
62Accepted312ms316 KiB
63Accepted389ms508 KiB
64Accepted1ms316 KiB
65Accepted9ms316 KiB
66Time limit exceeded600ms316 KiB
67Accepted1ms316 KiB
68Accepted18ms316 KiB
69Time limit exceeded600ms404 KiB
70Time limit exceeded578ms316 KiB
71Accepted14ms316 KiB
72Time limit exceeded575ms316 KiB
73Accepted93ms316 KiB
74Time limit exceeded575ms316 KiB
75Accepted1ms316 KiB
76Accepted1ms316 KiB
77Time limit exceeded600ms316 KiB
78Accepted1ms316 KiB
79Time limit exceeded600ms316 KiB
80Accepted25ms316 KiB
81Time limit exceeded583ms316 KiB