class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param op string字符串vector
* @param vals int整型vector<vector<>>
* @return int整型vector
*/
vector<int> max_weight_cow(vector<string>& op, vector<vector<int> >& vals) {
// write code here
int len = op.size();
vector<int> t;
vector<int> ans;
for(int i=0; i<len; ++i)
{
if(op[i]=="MaxCowStack")
{
ans.emplace_back(-1);
}
else if(op[i]=="push")
{
ans.emplace_back(-1);
t.emplace_back(vals[i][1]);
}
else if(op[i]=="getMax")
{
int max_num=0;
for(int j=0; j<t.size(); ++j)
max_num = max(max_num, t[j]);
ans.emplace_back(max_num);
}
else if(op[i]=="pop")
{
ans.emplace_back(-1);
t.pop_back();
}
else if(op[i]=="top")
{
ans.emplace_back(t.back());
}
}
return ans;
}
};