QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#575167 | #9313. Make Max | tilenn | WA | 0ms | 3576kb | C++23 | 897b | 2024-09-19 11:02:13 | 2024-09-19 11:02:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long LL;
void solve(){
int n;
cin >> n;
vector<int> a(n + 2);
a[0] = a[n + 1] = 1e9 + 1;
stack<int> stk;
vector<int> l(n + 1),r(n + 1);
stk.push(0);
for(int i = 1;i <= n;i++){
while(stk.size() && a[stk.top()] < a[i])stk.pop();
l[i] = stk.top();
stk.push(i);
}
while(stk.size())stk.pop();
stk.push(n + 1);
for(int i = n;i >= 1;i--){
while(stk.size() && a[stk.top()] < a[i])stk.pop();
r[i] = stk.top();
stk.push(i);
}
LL res = 0;
for(int i = 1;i <= n;i++){
res += r[i] - l[i] - 1;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
result:
wrong answer Answer contains longer sequence [length = 4], but output contains 0 elements