You are viewing a single comment's thread. Return to all comments →
don't know why, but it's not working!
int max(long int y, long int x) { return (y >= x ? y : x); } int main() { int n,type,top=-1; long int stack[100000],x; cin>>n; while(n--) { cin>>type; if(type==1) { cin>>x; if(top==-1) stack[++top]=x; else stack[++top]=max(stack[top],x); } if(type==2) --top; if(type==3) cout<<stack[top]<<endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
don't know why, but it's not working!