Only through the first case, do not know why.
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <stack> using namespace std;
Class mystack{public:stack<int> data;
Stack<int> datamin;
void Mypush (int tmp) {if (Data.empty ()) {Data.push (TMP);
Datamin.push (TMP);
Return
} if (Data.top () >= tmp) {Datamin.push (TMP);
}else{Datamin.push (Datamin.top ());
} data.push (TMP);
} void Mypop () {if (Data.empty ()) {return;
} data.pop ();
Datamin.pop ();
} void Mymin () {if (!data.empty ()) {printf ("%d\n", Datamin.top ());
}else{printf ("null\n");
}
}
};
int main () {int n;
char flag;
int datainput;
int i;
Mystack Stackdata; while (scanf ("%d", &n)! = EOF && n>=1 && n<=1000000) {if (n <= 0) {CoNtinue;
} for (i=0; i<n; ++i) {scanf ("\n%c", &flag);
if (flag = = = ' s ') {scanf ("%d", &datainput);
Stackdata.mypush (Datainput);
Stackdata.mymin ();
}else if (flag = = ' O ') {stackdata.mypop ();
Stackdata.mymin (); }} if (!stackdata.data.empty ()) {while (!stackdata.data.empty ()) {stackda
Ta.data.pop ();
Stackdata.datamin.pop ();
}}} return 0;
}/************************************************************** problem:1522 User: Star River Language:c++ Result:wrong Answer ****************************************************************/