QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#579206#9313. Make MaxeweWA 95ms5232kbC++141.2kb2024-09-21 10:34:012024-09-21 10:34:02

Judging History

你现在查看的是最新测评结果

  • [2024-09-21 10:34:02]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:5232kb
  • [2024-09-21 10:34:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define fopen                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) (x & -x)
#define i64 long long
#define pii pair<int, int>
#define de(x) cout << #x << " = " << x << '\n'

const int N = 2e5 + 10, M = 4e5 + 10, mod = 1e9 + 7;
const double eps = 1e-6;

int a[N], siz[N], n;

void solve()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i], siz[i] = 1;

    i64 ans = 0;
    for (int i = 1, j, pre; i <= n; ++i)
    {
        pre = a[i];
        j = i - 1;
        while (j > 0 && a[j] < a[i])
        {
            ans += siz[j];
            ans += siz[j] * (pre < a[j]);
            pre = a[j];
            siz[i] += siz[j];
            j -= siz[j];
        }
    }

    int mx = a[n];
    for (int i = n - siz[n]; i > 0; i -= siz[i])
        if (a[i] > mx)
        {
            mx = a[i];
            ans += n - i;
        }

    cout << ans << '\n';
}

signed main()
{
    // fopen;
    int t = 1;
    cin >> t;

    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
3
3

result:

ok 4 number(s): "1 0 3 3"

Test #2:

score: -100
Wrong Answer
time: 95ms
memory: 5232kb

input:

2
198018
875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...

output:

4149241
4067689

result:

wrong answer 1st numbers differ - expected: '4084978', found: '4149241'