QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578853 | #9313. Make Max | eden369 | Compile Error | / | / | C++14 | 910b | 2024-09-20 21:56:05 | 2024-09-20 21:56:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int N=1e6+10;
int a[N];
vector<int>st;
int main(){
int t;
cin>>t;
while(t--)
{
int ans=0;
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
a[n+1]=1e9+1;
st={0};
int ans=0;
for(int i=1;i<=n;i++)
{
while(!st.empty()&&a[st.back()]<a[i])
{
st.pop_back();
}
ans+=i-st.back()-1;
st.push_back(i);
}
st={n+1};
for(int i=n;i>=1;i--)
{
while(!st.empty()&&a[st.back()]<a[i])
{
st.pop_back();
}
if(a[st.back()]!=a[i])ans+=st.back()-i-1;
st.push_back(i);
}
cout<<ans<<endl;
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:22:13: error: redeclaration of ‘int ans’ 22 | int ans=0; | ^~~ answer.code:13:13: note: ‘int ans’ previously declared here 13 | int ans=0; | ^~~