QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#568308#9313. Make MaxlmhWA 1ms5780kbC++14643b2024-09-16 16:00:412024-09-16 16:00:44

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 16:00:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5780kb
  • [2024-09-16 16:00:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t,n;
int a[400010],l[400010],r[400010];
signed main(){
	cin>>t;
	while(t--){
		int ans=0;
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		for(int i=1;i<=n;i++){
			int j=i-1;
			while(a[j]<a[i]&&j>=1){
				j--;
			}
			l[i]=j+1;
			j=i+1;
			while(a[j]<a[i]&&j<=n){
				j++;
			}
			r[i]=j-1;
		}
		for(int i=1;i<=n;i++){
			cout<<l[i]<<" ";
		}cout<<endl;
		for(int i=1;i<=n;i++)
			cout<<r[i]<<" ";
		cout<<endl;
		for(int i=1;i<=n;i++)
			ans=ans+(i-l[i])+(r[i]-i);
		cout<<ans<<endl;
	}
	return 0;
}
/*
4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5780kb

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
1 2 
1 2 
0
1 2 3 1 5 6 7 
1 2 3 4 5 6 7 
3
1 1 1 
1 2 3 
3

result:

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