QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#238101#5693. 众数to_the_immaculateWA 12ms4392kbC++14883b2023-11-04 15:47:102023-11-04 15:47:10

Judging History

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

  • [2023-11-04 15:47:10]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:4392kb
  • [2023-11-04 15:47:10]
  • 提交

answer

#include<iostream>
#include<vector>
using namespace std;
#define int long long 
const int N = 1e5 + 10;
int a[N];
vector<pair<int,int> > ve;
signed main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> a[i];
	}
	int ans = 0;
	ans += a[n] * n;
	for(int i = n - 1; i >= 1; i --)
	{
		if(a[i] > a[n])
		{
			ans += a[n] * n;
			ve.push_back({i,a[i] - a[n]});
		}
		if(a[i] <= a[n])
		{
			ans += a[i] * n;
		}
	}
	while(ve.size())
	{
		int now = ve[0].first;
		int c = ve[0].second;
		ans += c * now;
		ve.erase(ve.begin());
		for(int i = 0; i < ve.size(); i ++)
		{
			if(ve[i].second > c)
			{
				ans += (ve[i].second - c) * now;
				ve[i].second = ve[i].second - c;
				continue;
			}
			if(ve[i].second <= c)
			{
				ans += ve[i].second * now;
				ve.erase(ve.begin() + i);
			}
		}
	}
	cout << ans;
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 4392kb

input:

99991
3 3 3 4 3 6 4 2 2 5 3 2 3 5 3 3 2 1 2 3 4 2 3 4 3 3 3 4 3 3 3 2 3 2 3 2 4 3 3 2 3 5 3 5 4 2 4 3 3 1 3 2 2 3 4 2 3 3 2 2 4 5 3 2 3 3 1 3 3 4 1 3 4 5 1 1 3 4 2 4 3 2 5 3 3 2 2 2 4 2 4 2 2 4 2 4 3 3 2 3 2 2 1 4 3 1 3 1 2 2 3 1 1 5 2 1 2 2 3 3 1 4 4 4 3 3 3 3 1 3 3 5 5 4 4 3 3 3 4 3 6 5 3 1 1 2 2 ...

output:

4973061883024

result:

wrong answer 1st lines differ - expected: '4973056284288', found: '4973061883024'