QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584318 | #9313. Make Max | sssbbb | WA | 0ms | 3528kb | C++14 | 1.0kb | 2024-09-23 11:58:04 | 2024-09-23 11:58:07 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
vector<int> a(n + 2);
a[0] = a[n + 1] = 2e9;
for(int i = 1; i <= n; i++) cin >> a[i];
LL ans = 0;
{
vector<int> stk{0};
for(int i = 1; i <= n; i++){
while(!stk.empty() and a[stk.back()] <= a[i]){
stk.pop_back();
}
ans += i - stk.back() - 1;
stk.push_back(i);
}
}
{
vector<int> stk{n + 1};
for(int i = n; i >= 1; i--){
while(!stk.empty() and a[stk.back()] <= a[i]) stk.pop_back();
ans += stk.back() - i - 1;
stk.push_back(i);
}
}
cout << ans << '\n';
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 2 30 3
result:
wrong answer 2nd numbers differ - expected: '0', found: '2'