class Solution {
public:
int minCostClimbingStairs(vector<int>& cost) {
cost.push_back(0);
int p1=cost[1],p2=cost[0];
for(int i=2;i<cost.size();i++){
int tmp=p1;
p1=min(p1,p2)+cost[i];
p2=tmp;
}
return min(p1,p2);
}
};