| 19873 | 2025-12-28 12:46:08 | madvir | Megrendelések | cpp17 | Compilation error |
#include <iostream>
#include <algorithm>
using namespace std;
struct rendeles {
int sor, hat;
};
bool rule(rendeles x, rendeles y) {
return x.hat<y.hat;
}
int main() {
int n, m, k;
cin >> n >> m >> k;
rendeles a[10001];
for(int i=1; i<=m; i++) {
cin >> a[i].hat;
a[i].sor=i;
}
sort(a+1, a+m+1, rule);
///until here its the exact same, except for the fact that shes using a vector.
//she is using a struct too, with the same values: ind=sor, ido=hat
//r is a for her, jo is b. imma change this too, to make things easier for myself
rendeles b[10001];
//lets change this while to check each day
int t=0, nc=1, lim=0, veg=0, ag=1, bg=1;
while(nc<=n) {
while(a[ag].hat>=nc && lim<k && ag<=m) {
b[bg].sor=a[ag].sor;
b[bg].hat=nc;
bg++;
ag++;
lim++;
}
nc++;
}
cout << bg-1 << endl;
for(int i=1; i<jg; i++) {
cout << b[i].sor << " " << b[i].hat;
}
return 0;
}open /var/local/lib/isolate/434/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:44:20: error: 'jg' was not declared in this scope; did you mean 'bg'?
44 | for(int i=1; i<jg; i++) {
| ^~
| bg