QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573497 | #9313. Make Max | wxsq | WA | 0ms | 3624kb | C++20 | 957b | 2024-09-18 19:01:35 | 2024-09-18 19:01:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
int n; cin >> n;
vector<int>a(n+1);
for(int i = 1 ; i <= n ; i++) {
cin >> a[i];
}
ll ans = 0;
vector<int>stk;
vector<int>anss(n+1);
for(int i = 1 ; i <= n ; i++){
while(!stk.empty() && a[stk.back()] < a[i]) stk.pop_back();
if(!stk.empty()) ans += i-stk.back()-1;
else ans += i-1;
cout<<ans<<" "<<a[i]<<endl;
stk.push_back(i);
}
vector<int>stk2;
for(int i = n ; i >= 1 ; i--){
while(!stk2.empty() && a[stk2.back()] < a[i]) stk2.pop_back();
if(!stk2.empty() && a[i]!=a[stk2.back()]) ans += stk2.back()-i-1;
else if(stk2.empty())ans += n-i;
cout<<ans<<" "<<a[i]<<endl;
stk2.push_back(i);
}
cout<<ans<<endl;
}
int main()
{
int t; cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
0 1 1 2 1 2 1 1 1 0 2 0 2 0 2 0 2 0 0 1 0 1 0 1 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 1 3 1 3 1 3 0 1 1 2 3 3 3 3 3 2 3 1 3
result:
wrong answer 1st numbers differ - expected: '1', found: '0'