| 19880 | 2025-12-28 14:41:34 | madvir | Mekk Mester munkái (50 pont) | cpp17 | Compilation error |
#include <iostream>
#include <vector>
using namespace std;
struct munka {
int ind,k,v, done=0;
};
bool rule(munka x, munka y) {
return x.k<y.k;
}
int main() {
int n, h;
cin >> n >> h;
vector<munka> m;
vector<munka> g1, g2;
for(int i=1; i<=n; i++) {
cin >> m[i].k >> m[i].v;
m[i].ind=i;
}
sort(m.begin()+1,m.end(),rule);
int nc=1, q=1;
//eloszor az apa
while(nc<=h) {
while(m[q].k<nc && q<=n) q++;
if(q<=n) {
m[q].done=1;
nc=m[q].v+1;
g1.push_back(m[q]);
}
else nc=h+1;
}
//then the son
nc=1; q=1;
while(nc<=h) {
while(m[q].k<nc && q<=n) q++;
if(q<=n) {
if(m[q].done==0) {
nc=m[q].v+1;
g2.push_back(m[q]);
}
else q++;
}
else nc=h+1;
}
cout << g1.size() << " " << g2.size() << endl;
for(int i=1; i<=g1.size(); i++) {
cout << g1[i].ind << " ";
}
cout << endl;
for(int i=1; i<=g2.size(); i++) {
}
return 0;
}open /var/local/lib/isolate/410/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:23:5: error: 'sort' was not declared in this scope; did you mean 'short'?
23 | sort(m.begin()+1,m.end(),rule);
| ^~~~
| short