QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#566926 | #9313. Make Max | sunup15 | WA | 0ms | 3772kb | C++20 | 893b | 2024-09-16 03:36:15 | 2024-09-16 03:36:15 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
void solve(){
int n;
std::cin >> n;
std::vector<int> a(n + 2, INT32_MAX - 1);
for (int i = 1; i <= n; i++) std::cin >> a[i];
int ans = 0;
std::vector<std::pair<int,int>> stk;
std::function<void()> fun = [&]() -> void {
stk.push_back({INT32_MAX, 0});
for (int i = 1; i <= n; i++) {
if (stk.back().first > a[i]) {
stk.push_back({a[i], i});
} else {
while (stk.back().first <= a[i]) {
ans += i - stk.back().second - 1;
stk.pop_back();
}
stk.push_back({a[i], i});
}
}
while (stk.size()) stk.pop_back();
};
fun();
std::reverse(a.begin(),a.end());
fun();
std::cout << ans << '\n';
}
signed main(){
std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
int _ = 1;
std::cin >> _;
while (_) solve(), --_;
return (0^_^0);
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3772kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
0 0 0 0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'