#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; stack<int> stk; for(int i=1;i<=n;i++) { int x; cin>>x; while(stk.size()&&stk.top()==x) { x++; stk.pop();//删除 //stk.push(x); } stk.push(x); } cout<<stk.size(); return 0; }
Using your lizikid universal account