QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570941#9313. Make MaxSDTBU_LCYWA 132ms6772kbC++171.2kb2024-09-17 19:18:262024-09-17 19:18:28

Judging History

This is the latest submission verdict.

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-17 19:18:28]
  • Judged
  • Verdict: WA
  • Time: 132ms
  • Memory: 6772kb
  • [2024-09-17 19:18:26]
  • Submitted

answer

#include <iostream>
#include <queue>
using namespace std;
#define int long long
#define N 200005
int a[N];
priority_queue <int> q;
signed main()
{
    int _;
    cin >> _;
    while(_--)
    {
        int n;
        cin >> n;
        int mx = 0;
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            mx = max(mx, a[i]);
        }
        a[n + 1] = mx;
        int ans = 0;
        for(int i = 1; i <= n + 1; i++)
        {
            if(a[i] == mx)
            {
                if(!q.empty())
                {
                    int pre = mx, cnt = 0;
                    while(!q.empty())
                    {
                        if(q.top() == pre)
                        {
                            ans += cnt;
                            q.pop();
                        }
                        else
                        {
                            cnt++;
                            ans += cnt;
                            pre = q.top();
                            q.pop();
                        }
                    }
                }
            }
            else
                q.push(a[i]);
        }
        cout << ans << endl;
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
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:

1
0
3
3

result:

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

Test #2:

score: -100
Wrong Answer
time: 132ms
memory: 6772kb

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:

10025097930
12648227952

result:

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