QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576305 | #9320. Find the Easiest Problem | 22333322 | WA | 0ms | 4020kb | C++14 | 938b | 2024-09-19 19:51:59 | 2024-09-19 19:51:59 |
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: 4020kb
input:
2 5 teamA A accepted teamB B rejected teamC A accepted teamB B accepted teamD C accepted 4 teamA A rejected teamB A accepted teamC B accepted teamC B accepted
output:
0-1
result:
wrong answer 1st lines differ - expected: 'A', found: '0-1'