230632026-01-16 11:31:37SpoonMunkákcpp17Time limit exceeded 0/80688ms65536 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct munkak {
    int a;
    int h;
    int sorszam;
    int ertek=0;
    int megbizasok_szama = 0;
};


int n,m;
vector<munkak> megbizas;
vector<vector<int>> tarol;
int profit=0;

int comp(const munkak &x, const munkak &y) {
    return x.a < y.a;
}

void beolvas() {
    cin>>n>>m;
	megbizas.resize(m);
    tarol.resize(m);
    for (int i = 0;i < m;i++) {
		cin >> megbizas[i].a >> megbizas[i].h;
		megbizas[i].sorszam = i + 1;
        megbizas[i].ertek = megbizas[i].h;
    }
	sort(megbizas.begin(), megbizas.end(), comp);
	for (int i = 0;i < m-2;i++) {
		if (megbizas[i].a == megbizas[i + 1].a) {
			if (megbizas[i].h < megbizas[i + 1].h) {
				megbizas.erase(megbizas.begin() + i);
                m--;
				i--;
            }
            else {
				megbizas.erase(megbizas.begin() + i + 1);
				m--;
				i--;
            }
        }
    }
    megbizas[0].megbizasok_szama=1;
	megbizas[1].megbizasok_szama = 1;
	for (int i = 0;i < m;i++) {
        tarol[i].push_back(megbizas[i].sorszam);
    }
}

void feladat() {
    for (int i = 0;i < m;i++) {
        int maxi=0;
        int megbizszam=1;
        int legjobb=-1;
        for (int j = 0;j < i-1;j++) {
            if (megbizas[j].ertek > maxi) {
                maxi = megbizas[j].ertek;
                megbizszam=megbizas[j].megbizasok_szama+1;
                legjobb=j;
            }
        }
        megbizas[i].ertek=megbizas[i].ertek+maxi;
        megbizas[i].megbizasok_szama=megbizszam;
        if (legjobb != -1) {
            for(int j=0;j<tarol[legjobb].size();j++){
				tarol[i].push_back(tarol[legjobb][j]);
            }
        }
    }   
}



void kiir() {
    for (int i = 0;i < m;i++) {
        if (megbizas[i].ertek > profit) {
            profit=i;
        }
    }
    cout<<megbizas[profit].ertek<<" "<<megbizas[profit].megbizasok_szama<<endl;
    sort(tarol[profit].begin(),tarol[profit].end());
    for (int i = 0;i < tarol[profit].size();i++) {
        cout<<tarol[profit][i]<<" ";
    }
}

int main()
{
	beolvas();
    cout<<endl;
    feladat();
    kiir();


	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Time limit exceeded677ms4660 KiB
subtask20/10
3Accepted1ms316 KiB
4Wrong answer1ms316 KiB
5Wrong answer2ms316 KiB
6Accepted2ms316 KiB
7Wrong answer1ms316 KiB
subtask30/10
8Wrong answer1ms316 KiB
9Wrong answer1ms496 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
subtask40/10
13Accepted1ms316 KiB
14Wrong answer1ms316 KiB
15Wrong answer2ms316 KiB
16Accepted2ms316 KiB
17Wrong answer1ms316 KiB
18Wrong answer1ms316 KiB
19Wrong answer1ms316 KiB
20Accepted1ms316 KiB
21Wrong answer1ms316 KiB
22Wrong answer1ms316 KiB
subtask50/10
23Wrong answer1ms316 KiB
24Wrong answer1ms496 KiB
25Wrong answer1ms316 KiB
26Wrong answer1ms316 KiB
27Wrong answer1ms316 KiB
28Wrong answer1ms316 KiB
29Wrong answer1ms316 KiB
30Wrong answer1ms316 KiB
31Wrong answer1ms316 KiB
32Wrong answer1ms316 KiB
subtask60/10
33Accepted1ms316 KiB
34Wrong answer1ms316 KiB
35Wrong answer2ms316 KiB
36Accepted2ms316 KiB
37Wrong answer1ms316 KiB
38Wrong answer1ms316 KiB
39Wrong answer1ms496 KiB
40Wrong answer1ms316 KiB
41Wrong answer1ms316 KiB
42Wrong answer1ms316 KiB
43Wrong answer1ms316 KiB
44Wrong answer1ms316 KiB
45Accepted1ms316 KiB
46Wrong answer1ms316 KiB
47Wrong answer1ms316 KiB
48Wrong answer1ms316 KiB
49Wrong answer1ms316 KiB
50Wrong answer1ms316 KiB
51Wrong answer1ms316 KiB
52Wrong answer1ms316 KiB
53Wrong answer1ms316 KiB
54Wrong answer1ms316 KiB
55Wrong answer1ms316 KiB
56Wrong answer1ms316 KiB
57Wrong answer1ms316 KiB
subtask70/10
58Accepted1ms316 KiB
59Wrong answer1ms316 KiB
60Wrong answer2ms316 KiB
61Accepted2ms316 KiB
62Wrong answer1ms316 KiB
63Wrong answer1ms316 KiB
64Wrong answer1ms496 KiB
65Wrong answer1ms316 KiB
66Wrong answer1ms316 KiB
67Wrong answer1ms316 KiB
68Wrong answer1ms316 KiB
69Wrong answer1ms316 KiB
70Accepted1ms316 KiB
71Wrong answer1ms316 KiB
72Wrong answer1ms316 KiB
73Wrong answer1ms316 KiB
74Wrong answer1ms316 KiB
75Wrong answer1ms316 KiB
76Wrong answer1ms316 KiB
77Wrong answer1ms316 KiB
78Wrong answer1ms316 KiB
79Wrong answer1ms316 KiB
80Wrong answer1ms316 KiB
81Wrong answer1ms316 KiB
82Wrong answer1ms316 KiB
83Runtime error456ms65536 KiB
84Runtime error449ms65536 KiB
85Runtime error449ms65536 KiB
86Runtime error458ms65536 KiB
87Runtime error451ms65536 KiB
subtask80/20
88Accepted1ms316 KiB
89Wrong answer1ms316 KiB
90Wrong answer2ms316 KiB
91Accepted2ms316 KiB
92Wrong answer1ms316 KiB
93Wrong answer1ms316 KiB
94Wrong answer1ms496 KiB
95Wrong answer1ms316 KiB
96Wrong answer1ms316 KiB
97Wrong answer1ms316 KiB
98Wrong answer1ms316 KiB
99Wrong answer1ms316 KiB
100Accepted1ms316 KiB
101Wrong answer1ms316 KiB
102Wrong answer1ms316 KiB
103Wrong answer1ms316 KiB
104Wrong answer1ms316 KiB
105Wrong answer1ms316 KiB
106Wrong answer1ms316 KiB
107Wrong answer1ms316 KiB
108Wrong answer1ms316 KiB
109Wrong answer1ms316 KiB
110Wrong answer1ms316 KiB
111Wrong answer1ms316 KiB
112Wrong answer1ms316 KiB
113Runtime error456ms65536 KiB
114Runtime error449ms65536 KiB
115Runtime error449ms65536 KiB
116Runtime error458ms65536 KiB
117Runtime error451ms65536 KiB
118Time limit exceeded681ms4660 KiB
119Time limit exceeded683ms4660 KiB
120Time limit exceeded681ms4548 KiB
121Time limit exceeded681ms4912 KiB
122Time limit exceeded686ms4660 KiB
123Time limit exceeded688ms4660 KiB
124Time limit exceeded688ms4884 KiB
125Time limit exceeded686ms4856 KiB
126Time limit exceeded677ms4660 KiB
127Time limit exceeded677ms4852 KiB