#include <bits/stdc++.h>
using namespace std;
class House{
public:
int x,y;
House(int x,int y){
this->x=x;
this->y=y;
}
int Area(){
return (xx)+(yy);
}
void print(){
cout<<(xx)+(yy)<<endl;
}
};
class HouseComp{
bool operator()(House a,House b){
return a.Area()>b.Area();
}
};
int main() {
int q,t=0,k;
priority_queue <House,vector,HouseComp> pq;
vectorv1;
cin>>q>>k;
while(qā){
int t,x1,y1,d;
d=k;
cin>>t;
if(t==1){
cin>>x1>>y1;
House h(x1,y1);
pq.push(h);
}
else{
while(dā){
House h1=pq.top();
v1.push_back(h1);
pq.pop();
}
House h1=pq.top();
cout<<h1.print();
while(!v1.empty()){
pq.push(v1.front());
v1.pop_front();
}
}
}
return 0;
}
Compile time error And i m not knowing what it is
Hi @rishravi937 one major mistake I can see in your code is that you have used cout << h1.print( ). Here " cout << " will print what is returned by h1.print( ), however the return type of h1.print( ) is void so it does not return anything.
Either make h1.print return the value you want to print or dont use cout simply call the function and let it print the value.
Let me know if it helps.