QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568308 | #9313. Make Max | lmh | WA | 1ms | 5780kb | C++14 | 643b | 2024-09-16 16:00:41 | 2024-09-16 16:00:44 |
Judging History
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'