标签:nbsp log code 51nod int const ext amp ret
#include<bits/stdc++.h> using namespace std; const int maxn = 100100; int a[maxn],b[maxn]; stack<int>s; int main() { int n; cin >> n; for(int i=1;i<=n;i++) cin>>a[i]>>b[i]; int ans =0; for(int i=1;i<=n;i++) { ans++; if(b[i] ) s.push(a[i]); else { while(!s.empty() && a[i] > s.top() ) { ans--; s.pop(); } if(!s.empty() && a[i] < s.top()) { ans--; } } } cout<< ans<<endl; }
标签:nbsp log code 51nod int const ext amp ret
原文地址:http://www.cnblogs.com/Draymonder/p/7522113.html