QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567131 | #9313. Make Max | KagaMiku39 | WA | 0ms | 3860kb | C++14 | 907b | 2024-09-16 08:20:24 | 2024-09-16 08:20:24 |
Judging History
answer
#include <iostream>
#include <unordered_map>
#include <algorithm>
using namespace std;
using ll = long long;
struct Node{
ll cnt;
int v;
};
unordered_map<ll, Node> s;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t --) {
unordered_map<ll, Node>().swap(s);
int n; cin >> n;
int p = 0;
ll ans = 0;
for (int i = 1; i <= n; i ++) {
int v; cin >> v;
ll cnt = 1;
while (p > 1 && s[p - 1].v < v) {
s[p - 1].cnt += s[p].cnt;
ans += s[p].cnt;
p --;
}
while (p && s[p].v <= v) {
if (s[p].v != v) ans += s[p].cnt;
cnt += s[p].cnt;
p --;
}
cout << v << ' ' << cnt << ' ' << ans << endl;
s[++ p] = Node{cnt, v};
}
if (p != 1) {
int v = s[1].v;
ll cnt = 0;
while (p && s[p].v < v) {
cnt += s[p].cnt;
p --;
}
}
cout << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3860kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 1 0 2 2 1 1 2 1 0 2 2 0 0 1 1 0 1 2 0 1 3 0 2 4 3 2 5 3 2 6 3 2 7 3 3 1 1 0 2 2 1 3 3 3 3
result:
wrong answer 2nd numbers differ - expected: '0', found: '1'