QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#566957 | #9313. Make Max | Kidding_Ma | WA | 0ms | 3636kb | C++17 | 1.2kb | 2024-09-16 04:14:13 | 2024-09-16 04:14:14 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = int64_t;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
list<int> l;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> q;
vector<int> cnt(n, 1);
vector<list<int>::iterator> d(n);
for (int i = 0; i < n; i++) {
q.emplace(a[i], i);
l.push_back(i);
d[i] = prev(l.end());
}
int ans = 0;
while (!q.empty() && l.size() > 1) {
auto [ai, i] = q.top();
q.pop();
int mn = 1e9;int id;
auto it = d[i];int j;
if (it != prev(l.end())){
mn = a[*next(it)];
id = *next(it);
}
if (it != l.begin() && a[*prev(it)] < mn){
mn = a[*prev(it)];
id = *prev(it);
}
cnt[j] += cnt[i];
if (mn != a[i]){ // hebing
ans += cnt[i];
}
l.erase(it);
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3636kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
2 0 1 3
result:
wrong answer 1st numbers differ - expected: '1', found: '2'