QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575987#9313. Make MaxlpWA 336ms13680kbC++14827b2024-09-19 17:45:502024-09-19 17:45:51

Judging History

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

  • [2024-09-19 17:45:51]
  • 评测
  • 测评结果:WA
  • 用时:336ms
  • 内存:13680kb
  • [2024-09-19 17:45:50]
  • 提交

answer

#include<algorithm>//sort
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<utility>//pair
#include<map>
#include<stack>
#include<vector>
//#define int long long
using namespace std;
void so()
{
	int n,s;
	long long sum = 0;
	stack<int>q;
	map<int, int>ma;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> s;
		ma[s] = 1;
		while (q.size() && q.top()<s)
		{
			ma[s] += ma[q.top()];
			sum += ma[q.top()];
			q.pop();
		}
		q.push(s);
	}
	int a[200005];
	n = q.size();
	while (q.size())
	{
		a[q.size()] = q.top();
		q.pop();
	}
	int ss = 0;
	for (int i = n; i >= 2; i--)
	{
		if (a[i] != a[i - 1])
		{
			sum += a[i];
		}
		ss += a[i];
	}
	cout << sum << endl;
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		so();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 336ms
memory: 13680kb

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:

7777838287
8108870249

result:

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