//(栈)poj3250将第i头牛能看到多少牛传化为第i头牛能被多少牛看见 /* #include <stdio.h> #include <stack> using namespace std; int main(){ unsigned long N,ans=0; stack<unsigned long>s; scanf("%ld",&N); while(N--){ unsigned long cowHigh; scanf("%ld",&cowHigh); while(!s.empty()&&s.top()<=cowHigh) s.pop(); ans+=s.size(); s.push(cowHigh); } printf("%ld",ans); return 0; } //*/
时间: 2024-12-14 09:53:03