哪位大佬帮忙看看为什么这个错了

P2866 [USACO06NOV] Bad Hair Day S

```cpp #include<bits/stdc++.h> using namespace std; stack<int>v; int m,in[800005],maxx[800005]; long long tot; int main() { freopen("testdata.in","r",stdin); scanf("%d",&m); for(long long i=1;i<=m;i++) cin>>in[i]; //in[m+1]=100000000000; //v.push(10000000); v.push(1); int i=1; while(!v.empty()&&i<=m+1) { i++; while(!v.empty()&&in[i]>in[v.top()]) { v.pop(); maxx[v.top()]=i; } v.push(i); } for(int j=1;j<=m;j++) if(maxx[j]!=0) { tot+=(maxx[j]-j-1); } else tot+=m-j; cout<<tot<<endl; return 0; } ```
by Nobody_Zhang @ 2019-01-19 18:36:54


|