QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568363 | #9313. Make Max | reisentyan | WA | 0ms | 3484kb | C++14 | 1.6kb | 2024-09-16 16:12:27 | 2024-09-16 16:12:27 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stdio.h>
#include<stack>
#include<list>
using namespace std;
#define ffp(x,y,z) for(int(x) = (y);(x)<=(z);(x++))
#define ffs(x,y,z) for(int(x) = (y);(x)>=(z);(x--))
#define pii pair<ll ,ll>
#define ll long long int
#define endl '\n'
#define q_ qd()
const int iINF = 0x3f3f3f3f;
const ll lINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1000000007;
long long qd() {
long long w = 1, c, ret;
while ((c = getchar()) > '9' || c < '0')
w = (c == '-' ? -1 : 1); ret = c - '0';
while ((c = getchar()) >= '0' && c <= '9')
ret = ret * 10 + c - '0';
return ret * w;
}
int num[200200];
struct N
{
int va;
int l;
int r;
};
int l[200200];
int r[200200];
stack<N>st;
int main()
{
int t = q_;
while (t--)
{
int n = q_;
ffp(i, 1, n)
{
num[i] = q_;
}
ffp(i, 1, n)
{
while (st.size() && st.top().va < num[i])
{
r[st.top().r] = i -st.top().r - 1;
st.pop();
}
if (st.size() == 0)
{
st.push({ num[i],i,i });
l[i] = i - 1;
continue;
}
else
{
if (st.top().va == num[i])
{
l[i] = i - st.top().r-1;
st.top().r = i;
}
else
{
l[i] = i - st.top().r - 1;
st.push({ num[i],i,i });
}
}
}
while (st.size())
{
r[st.top().r] = n - st.top().r;
st.pop();
}
ll ans = 0;
ffp(i, 1, n)
{
ans += l[i] + r[i];
cout << i << " " << l[i] << ' ' << r[i] << endl;
l[i] = 0; r[i] = 0;
num[i] = 0;
}
cout << ans << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3484kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 0 2 1 0 1 1 0 0 2 0 0 0 1 0 0 2 0 0 3 0 0 4 3 0 5 0 0 6 0 0 7 0 0 3 1 0 0 2 1 0 3 2 0 3
result:
wrong answer 3rd numbers differ - expected: '3', found: '0'