17882022-12-03 15:31:11kovacs.peter.18fBenzinkút üzemeltetés (55)cpp11Compilation error
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct point {
    int benefit = 0, distance = 0, last_index = 0;
};

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K, T, H;
    cin >> N >> K;
    vector<point> dpS(1000001);
    for (int i = 0, index = 1; i < N; i++) {
        cin >> T >> H;
        while (index <= T) {
            dpS[index] = dpS[index - 1];
            ++index;
        }
        if (T >= K && dpS[T - K].benefit + H > dpS[T].benefit) {
            dpS[T] = point{ dpS[T - K].benefit + H, T, i };
        }
        else if (H > dpS[T].benefit) {
            dpS[T] = point{ H, T, i };
        }
    }
    stack<point> answerS;
    answerS.push(dpS[T]);
    while (answerS.top().distance > K) {
        answerS.push(dpS[answerS.top().distance - K]);
    }
    cout << dpS[T].benefit << '\n' << answerS.size() << " ";
    while (!answerS.empty()) {
        cout << answerS.top().last_index + 1 << " ";
        answerS.pop();
    }
    cout << '\n';
}
Compilation error
exit status 1
main.cpp: In function 'int main()':
main.cpp:25:58: error: no matching function for call to 'point::point(<brace-enclosed initializer list>)'
   25 |             dpS[T] = point{ dpS[T - K].benefit + H, T, i };
      |                                                          ^
main.cpp:7:8: note: candidate: 'constexpr point::point()'
    7 | struct point {
      |        ^~~~~
main.cpp:7:8: note:   candidate expects 0 arguments, 3 provided
main.cpp:7:8: note: candidate: 'constexpr point::point(const point&)'
main.cpp:7:8: note:   candidate expects 1 argument, 3 provided
main.cpp:7:8: note: candidate: 'constexpr point::point(point&&)'
main.cpp:7:8: note:   candidate expects 1 argument, 3 provided
main.cpp:28:37: error: no matching function for call to 'point::point(<brace-enclosed initializer list>)'
   28 |             dpS[T] = point{ H, T, i };
      |                                     ^
main.cpp:7:8: note: candidate: 'constexpr point::point()'
    7 | struct point {
      |        ^~~~~
main.cpp:7:8: note...