QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#283104#5693. 众数miaowuTL 0ms0kbC++23508b2023-12-13 20:29:132023-12-13 20:29:14

Judging History

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

  • [2023-12-13 20:29:14]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-12-13 20:29:13]
  • 提交

answer

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

const int maxn = 1e5 + 5;
int n;
int arr[maxn];
set <int> s;
int ans;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> arr[i];
		if(arr[i])s.insert(i);
	}

	while(!s.empty()){
		set<int>::iterator it = s.end();
		ans += *(--it) * s.size();
		set <int> s2 = s;
		for(auto i : s2){
			if(--arr[i])continue;
			s.erase(i);
		}
	}

	cout << ans;
	return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

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:


result: