QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576309 | #9313. Make Max | 22333322 | WA | 0ms | 3808kb | C++14 | 938b | 2024-09-19 19:52:40 | 2024-09-19 19:52:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mxn=2e5+5,inf=1e9+1;
#define int long long
int a[mxn],t,n;
struct A
{
int pre,num,size;
};
signed main()
{
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",a+i);a[++n]=1e9+1;
stack<A>s;
s.push({inf,inf,0});
int ans=0,p=1;
while(p<=n)
{
A &x=s.top();
if(a[p]<x.num) s.push({x.num,a[p],1}),p++;
else if(a[p]==x.num) x.size++,p++;
else if(x.pre>a[p])
{
ans+=x.size;
x={x.pre,a[p],++x.size};
p++;
}
else if(x.pre<=a[p])
{
ans+=x.size;
s.pop();
s.top().size+=x.size;
}
}
printf("%lld",ans-n+1);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1033
result:
wrong answer 1st numbers differ - expected: '1', found: '1033'