QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578402#9313. Make MaxgoliterWA 0ms7920kbC++14703b2024-09-20 18:54:202024-09-20 18:54:21

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 18:54:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7920kb
  • [2024-09-20 18:54:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+5;
int n,a[N],l[N],r[N],stk[N];
int main(){
	int t;
	cin>>t;
	while(t--){
		ll ans=0;
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		int top=0;
		for(int i=1;i<=n;i++){
			while(top&&a[i]>a[stk[top]]){
				top--;
			}
			l[i]=stk[top]+1;
			stk[++top]=i;
		}
		top=0;stk[top]=n+1;
		for(int i=n;i>=1;i--){
			while(top&&a[i]>a[stk[top]]){
				top--;
			}
			r[i]=stk[top]-1;
			if(a[r[i]+1]==a[i]){
				r[i]=i;
			}
			stk[++top]=i;
		}
		for(int i=1;i<=n;i++){
			cout<<l[i]<<" "<<r[i]<<endl;
			ans+=r[i]-l[i];
		}
		printf("%lld\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7920kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1 1
1 2
1
4 1
2 2
-3
4 1
2 2
3 3
4 4
5 5
6 6
7 7
-3
9 1
9 2
9 3
-21

result:

wrong answer 2nd numbers differ - expected: '0', found: '1'