230732026-01-16 11:38:49SpoonMunkákcpp17Time limit exceeded 10/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-1;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--;
            }
        }
    }
	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
1Accepted1ms500 KiB
2Time limit exceeded688ms4660 KiB
subtask210/10
3Accepted2ms316 KiB
4Accepted1ms508 KiB
5Accepted2ms316 KiB
6Accepted2ms316 KiB
7Accepted1ms316 KiB
subtask30/10
8Wrong answer1ms500 KiB
9Wrong answer1ms316 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms500 KiB
12Wrong answer1ms316 KiB
subtask40/10
13Accepted2ms316 KiB
14Accepted1ms508 KiB
15Accepted2ms316 KiB
16Accepted2ms316 KiB
17Accepted1ms316 KiB
18Wrong answer1ms316 KiB
19Accepted1ms332 KiB
20Accepted1ms316 KiB
21Wrong answer1ms316 KiB
22Wrong answer1ms316 KiB
subtask50/10
23Wrong answer1ms500 KiB
24Wrong answer1ms316 KiB
25Wrong answer1ms316 KiB
26Wrong answer1ms500 KiB
27Wrong answer1ms316 KiB
28Wrong answer1ms316 KiB
29Wrong answer1ms316 KiB
30Wrong answer1ms316 KiB
31Wrong answer1ms508 KiB
32Wrong answer1ms316 KiB
subtask60/10
33Accepted2ms316 KiB
34Accepted1ms508 KiB
35Accepted2ms316 KiB
36Accepted2ms316 KiB
37Accepted1ms316 KiB
38Wrong answer1ms500 KiB
39Wrong answer1ms316 KiB
40Wrong answer1ms316 KiB
41Wrong answer1ms500 KiB
42Wrong answer1ms316 KiB
43Wrong answer1ms316 KiB
44Accepted1ms332 KiB
45Accepted1ms316 KiB
46Wrong answer1ms316 KiB
47Wrong answer1ms316 KiB
48Wrong answer1ms316 KiB
49Wrong answer1ms316 KiB
50Wrong answer1ms316 KiB
51Wrong answer1ms508 KiB
52Wrong answer1ms316 KiB
53Wrong answer1ms316 KiB
54Wrong answer1ms316 KiB
55Wrong answer1ms316 KiB
56Wrong answer1ms316 KiB
57Wrong answer1ms316 KiB
subtask70/10
58Accepted2ms316 KiB
59Accepted1ms508 KiB
60Accepted2ms316 KiB
61Accepted2ms316 KiB
62Accepted1ms316 KiB
63Wrong answer1ms500 KiB
64Wrong answer1ms316 KiB
65Wrong answer1ms316 KiB
66Wrong answer1ms500 KiB
67Wrong answer1ms316 KiB
68Wrong answer1ms316 KiB
69Accepted1ms332 KiB
70Accepted1ms316 KiB
71Wrong answer1ms316 KiB
72Wrong answer1ms316 KiB
73Wrong answer1ms316 KiB
74Wrong answer1ms316 KiB
75Wrong answer1ms316 KiB
76Wrong answer1ms508 KiB
77Wrong answer1ms316 KiB
78Wrong answer1ms316 KiB
79Wrong answer1ms316 KiB
80Wrong answer1ms316 KiB
81Wrong answer1ms316 KiB
82Wrong answer1ms316 KiB
83Runtime error449ms65536 KiB
84Runtime error455ms65536 KiB
85Runtime error449ms65536 KiB
86Runtime error456ms65536 KiB
87Runtime error463ms65536 KiB
subtask80/20
88Accepted2ms316 KiB
89Accepted1ms508 KiB
90Accepted2ms316 KiB
91Accepted2ms316 KiB
92Accepted1ms316 KiB
93Wrong answer1ms500 KiB
94Wrong answer1ms316 KiB
95Wrong answer1ms316 KiB
96Wrong answer1ms500 KiB
97Wrong answer1ms316 KiB
98Wrong answer1ms316 KiB
99Accepted1ms332 KiB
100Accepted1ms316 KiB
101Wrong answer1ms316 KiB
102Wrong answer1ms316 KiB
103Wrong answer1ms316 KiB
104Wrong answer1ms316 KiB
105Wrong answer1ms316 KiB
106Wrong answer1ms508 KiB
107Wrong answer1ms316 KiB
108Wrong answer1ms316 KiB
109Wrong answer1ms316 KiB
110Wrong answer1ms316 KiB
111Wrong answer1ms316 KiB
112Wrong answer1ms316 KiB
113Runtime error449ms65536 KiB
114Runtime error455ms65536 KiB
115Runtime error449ms65536 KiB
116Runtime error456ms65536 KiB
117Runtime error463ms65536 KiB
118Time limit exceeded685ms4660 KiB
119Time limit exceeded685ms4660 KiB
120Time limit exceeded685ms4660 KiB
121Time limit exceeded685ms4852 KiB
122Time limit exceeded681ms4660 KiB
123Time limit exceeded683ms4660 KiB
124Time limit exceeded683ms4660 KiB
125Time limit exceeded683ms4660 KiB
126Time limit exceeded674ms4660 KiB
127Time limit exceeded675ms4660 KiB